Solved

Inheritance

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 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.

744 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

12 Experts available now in Live!

Get 1:1 Help Now