How do u "cin" values into members of a class. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do u "cin" values into members of a class.

I wanted to "cin" an integer value for a class member, it gave a compiler error.

23rd Apr 2019, 2:17 PM
Segmentation Fault
Segmentation Fault - avatar
2 Answers
0
Is the class member public? That would be a precondition of course. Otherwise cin >> instance.value; should work... (although you'd normally rather use a setter). Let me run and try this. ;-) EDIT: Works as expected.
23rd Apr 2019, 6:19 PM
HonFu
HonFu - avatar
0
class member is public, HonFu
23rd Apr 2019, 6:30 PM
Segmentation Fault
Segmentation Fault - avatar