Solved

Inheritance

Posted on 1998-12-15
4
256 Views
Last Modified: 2010-04-02
1)if Class A is base class for Class B then the private data members of base class are inherited or not?
I think they are inherited but we can't access them.

2)Protected data members of base class can be accessed by object of a derived class or only public member function of derived class.
0
Comment
Question by:manjucee
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
pagladasu earned 50 total points
ID: 1180255
1)
Private members of the base class are part of the derived class object - however, as you had specified, they cannot be accessed by derived class member functions.
2)
Protected members of base class may become protected or private in the derived class, depending on the type of derivation - and as such can be accessed only by member functions of the derived class.
I am providing this answer, not taking into consideration friend classes and functions
thanks
pagladasu
0
 

Author Comment

by:manjucee
ID: 1180256
Hi pagladasu,
         Thanks for clarifying the doubts.
Thanks
Manju
0
 

Author Comment

by:manjucee
ID: 1180257
Hi pagladasu,
                        if i inherit baseclass privately  then also the private data members are inherited and only thing is that i can't access them in derived class. (Y/N)
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180258
You are welcome. Just for curiosity - are you new to C++. If you face any problems, feel free to post it at my mail:espical@hotmail.com
pagladasu
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question