Solved

Inheritance

Posted on 1998-12-15
4
255 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

770 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