- 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()??

9th Feb 2020, 7:13 PM
Mohamad Moussa
Mohamad Moussa - avatar
5 odpowiedzi
+ 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.
9th Feb 2020, 7:27 PM
HonFu
HonFu - avatar
+ 1
The decisive factor would be, if the method setName itself is public or not.
9th Feb 2020, 7:25 PM
HonFu
HonFu - avatar
+ 1
yeh sure it is
9th Feb 2020, 7:26 PM
Mohamad Moussa
Mohamad Moussa - avatar
+ 1
perfect ty
9th Feb 2020, 7:28 PM
Mohamad Moussa
Mohamad Moussa - avatar
+ 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.
9th Feb 2020, 9:22 PM
Ipang