Solved

Inheritance

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now