+ 1

what will be the output of the program? and why string name is private?what was the effect of private string name?

class myClass { public: void setName(string x) { name = x; } string getName() { return name; } private: string name; };

25th Sep 2017, 5:53 PM
Shivani Goyal
1 Antwort
+ 7
There is no output in the code that is posted. name is private so that the variable cannot be accessed directly, but must be accessed via a method of the class.
25th Sep 2017, 6:04 PM
ChaoticDawg
ChaoticDawg - avatar