Ask question, find answer on any topic in real time from people around the world. Have a question ? Ask now. Know an Answer share your Knowledge to world.PrepJunk is the online community that has Junk of answers!
UNITED STATES
1
1
online

What’s the difference between ‘public:’, ‘private:’, and ‘protected:’?

0

What’s the difference between ‘public:’, ‘private:’, and ‘protected:’?

asked Apr 7, 2012 in C++ by mohan (541 points)
    

1 Answer

0

‘Private’ is discussed in the previous section, and ‘public’ means ‘anyone can access it’. The third option, ‘protected’, makes a member (either data member or member fn) accessible to subclasses. Thus members defined in the

‘private:’ section of class X are accessible only
to the member functions and friends of class X; members defined in the
‘public:’ section are accessible by everyone; ‘protected:’ members are
accessible by members fns and friends of class X, as well as member fns of
subclasses of X.

answered Apr 7, 2012 by mohan (541 points)