top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C++: Do we have any way to access private members functions of a class from outside of class?

+2 votes
540 views
C++: Do we have any way to access private members functions of a class from outside of class?
posted Dec 29, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

You can play some dirty pointer trick (ie access a public member and move the pointer) but that is a undefined behaviour and one should not do that.

So simple answer is You can not. That member is private, it's not visible outside the class and the whole purpose of having private is to remain visible inside the class.

answer Dec 30, 2015 by Salil Agrawal
0 votes

Yes we can access private members functions using any public members functions of those class.

answer Dec 29, 2015 by Rajan Paswan
Question is about from different class
Yes the above process can be called in also different class.
...