How to modify a private data member of a class through a non member function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to modify a private data member of a class through a non member function?

pls guys help me in this question I am in very urgent of this answer.

16th May 2018, 3:36 AM
Code Ripper
Code Ripper - avatar
1 Answer
+ 2
You can use friend functions. They can access private variables of the class, but they are not member functions. I wrote an example for you to look at, but there is also a lesson on friends under the "More on Classes" section of the C++ unit. https://code.sololearn.com/ciKc8PDBE5W9/?ref=app
16th May 2018, 3:51 AM
Caroline