A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C++ program to access public data member inside main using object name.
Q:

C++ program to access public data member inside main using object name.

0

C++ program to access public data member inside main using object name.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C++ program (Code Snippet) – Accessing public data member (Variable) inside main function using Object Name

Let’s consider the following example:

/*C++ program to access public data member 
inside main using object name*/

#include <iostream>

using namespace std;

class Sample{
	public:
		int x;
};

int main(){
	Sample objSample;
	objSample.x=20;
	cout<<"value of x: "<<objSample.x<<endl;
	return 0;
}

Output

            value of x: 20

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now