Rules of inheritance, C/C++ Programming

Rules of Inheritance:

  • Private members are not inherited; the members can be accessed only within its class. It cannot be used through the object.
  • Protected members are inherited; but it can be used only within the base and inherited derived class. It cannot be accessed through the object.
  • Public members are inherited, and public members only can be accessed inside the class as well as outside the class through objects.
  • The private member and protected member can be accessed outside the class indirectly, that is passing these members in the public members.
  • Class inherited as private will make all the members of the base class as private in the derived class; and it has to follow the rules of private member to access.
  • Class inherited as protected will make all the members of the base class as protected in the derived class; and it has to follow the rules of protected member to access.
  • Class inherited as public will not make any changes to the members of base class in the derived class.
  • The derived class cannot modify the original characteristic of its base class.
  • The multiple copies of same class may happen during multiple inheritances. This can be avoided by created virtual base class using "public virtual" key word this make only one copy to be inherited from base classes.
  • Constructor is not inherited but arguments can be passed from the derived class to the base class constructor using colon operator.
  • Objects be able to nested, and it is not inheritance.
  • When the base class and the derived class has the same member function name, only the derived class member can be accessed through derived class object. In this case the base class member function is overridden. The base class member function can be accessed through derived class object only through scope operator if the derived as public.

 

 

Posted Date: 9/20/2012 8:21:05 AM | Location : United States







Related Discussions:- Rules of inheritance, Assignment Help, Ask Question on Rules of inheritance, Get Answer, Expert's Help, Rules of inheritance Discussions

Write discussion on Rules of inheritance
Your posts are moderated
Related Questions
How to Create A Data File? A data file should be created before it can be processed. A stream-oriented data file is able to be created in two ways. One is to create the file st

What is the use of PEAR in php? PEAR is termed as PHP Extension and Application Repository. It provides structured library to PHP users and also gives provision for package mai

write a program to find the area under the curve y=f(x) between x=a & x=b

What are the debugging methods you employ while came across a problem? A: Debugging with tools such as: 1.      DBG, GDB ,Forte, Visual Studio. 2.      Using tusc to trace

Employ operator () instead of operator[]. While you have multiple subscripts, the cleanest way to do it is along with operator () instead of with operator[]. The reason is that

How are postfix and prefix versions of operator++ () differentiated? A: The postfix version of operator++ () contain a dummy parameter of type int. The prefix version does not c

write a promgram using object oriented peramid

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

I need CSGO Wallhack and Human Aimbot Project Description: Need a CSGO hack which can ESP Wallhack and Aimbot realistically. Must be VAC Proof, and ESL proof, as wel

Algorithm for railway ticket booking process