+ 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; };
1 Réponse
+ 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.