+ 2
If there is a class and it has only one int type data member in it and that is also private. Can we use it outside the class?
Outside the class here doesn't symbolises to a friend function, it represents main(). And if we can access it outside the class then what does data abstraction mean then???
7 Respostas
+ 2
just make a class type object "A" and a class type pointer that is refering to that object "A"...
Now dereference it wherever you want. you will get the value of that data member.
+ 4
recently i learning c++.. and i think u cannot access a private data member outside the class..
If its public, then the data member can be easily accessed using the direct member access (.) operator with the object of that class. If, the data member is defined as private or protected, then we cannot access the data variables directly.
https://www.studytonight.com/cpp/accessing-data-members.php
+ 4
sure.. tell me
+ 3
sounds good...ok..i'll check later..
+ 1
bro actually there is one way. I may give you a hint if you want. It can be done using pointers...
0
actually I have got one way but don't know whether it is right or not???
0
ya sure please check it and tell me if it works bcz it's from my mind..
I too need to know whether it's right or not