Rules of inheritance, C/C++ Programming

Assignment Help:

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.

 

 


Related Discussions:- Rules of inheritance

Define the category of function - computer programming, Define the Category...

Define the Category of Function? A function, depending on whether arguments or parameters are present or not and whether a value returned or not, may belong to one of the foll

Memory management operator, Memory Management Operator In C malloc( ), ...

Memory Management Operator In C malloc( ), calloc( ), realloc( ), and free( ) are used to mange dynamic memory.  In addition to these function C++ have derived two unary ope

Linked list, program for singly linked list with out header

program for singly linked list with out header

Function, write a function named "fact"that takes one integer arguments,ca...

write a function named "fact"that takes one integer arguments,call them "num" and returns as ..............

Program, c | c-c-c-c-c | c-c-C-c-c | ...

c | c-c-c-c-c | c-c-C-c-c | c find distance between difftent carbon atom by programing

Pointers, Pointers are just numbers, representing addresses in memory. You ...

Pointers are just numbers, representing addresses in memory. You can add to and subtract from pointers, for instance. It is pretty easy to make mistakes with pointer math, however,

Lexicographic permutation, Given an integer n and a permutation of numbers ...

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd