- 1
Cin with private attributes
Does this mean if we want to take values and assign them to the private attributes we use for example: Cin>>className.setName()??
5 Réponses
+ 1
Then you should be good to go. The method setName becomes a sort of 'gate guard', controlling if and how the private variable will be changed.
+ 1
The decisive factor would be, if the method setName itself is public or not.
+ 1
yeh sure it is
+ 1
perfect ty
+ 1
Mohamad Moussa
Can you show the className definition? Somehow that line doesn't look like a valid statement to me. The right hand side operand is a function call rather than a variable, or anything that can receive data extracted by the input stream.
Comonly, a setter like `setName` takes an argument, which is used as new value for a member data. But in that code it takes none, I'm not sure how the data extracted is then passed as argument for `setName` setter function.