Welcome to GeekInterview.com
Your professional forum for technical and career related questions
- » You have a interview question or a tech faq and seek help?
- » You want to get an explanation of technical issues?
- » You have questions about your career?
- » You are fresher and concerned about your career?
...then you have come to the right place!
we will try to help you with your problem.
As we know derived class inherit all the features of Base class and it also add its own features ,data etc .............
When a class is inherited all the functions and data member are inherited, although not all of them will be accessible by the member functions of the derived class. But there are some exceptions to ........................
Some of the exceptions to be noted in C++ inheritance are as follows.
- The constructor and destructor of a base class are not inherited
- the assignment operator is not inherited
- the friend functions and friend classes of the base class are also not inherited.
It is a well known fact that the private and protected members are not accessible outside the class. But a derived class is given access to protected members of the base class
In C++ there are three inheritance access specifiers:
- public
- protected
- private
virtual keyword. In my experience interviewing candidates for c++ positions, I've learned that the average programmer does not know how these are used, or even what they mean. So I thought I would go over them here.The three access modifiers
public, protected and private are analogous to the access modifiers used for class members.- public
- When a base class is specified as
publicie:class c : public base {};the base class can be seen by anyone who has access to the derived class. That is, any members inherited frombasecan be seen by code accessingc. - protected
- When a base class is specified as
protectedie:class c : protected base {};the base class can only be seen by subclasses ofC. - private
- When a base class is specified as
privateie:class c : private base {};the base class can only be seen by the classCitself.

8:45 AM
Alice


0 comments:
Post a Comment