Skip to main content

Featured

functions in Python

how to solve inheritance problems class 12 cbse CS students

IMPORTANT RULES TO SOLVE PROBLEMS OF INHERITANCE especially for class 12 CBSE students
 
·         Class members mean: member data and member functions both.
·         Inside a Class all the members are accessible to one another whether private, public, protected or inherited.
·         Outside a class, an object of a class can access only public members of that class including the inherited members.
·         Constructors, Destructors and Private members of a class are not inherited.
·         To calculate the size of any class we add up all the data members of that class whether private, public or protected. If the class is derived, then add up the size of its Base class also.
 
·   How the members are inherited in different derivation modes: In the following diagrams, Class B is deriving from Class A in three different modes - private, public and protected.  

public derivation

 
private derivation
 

protected derivation

 
 
·         Storage Size for different data types is as follows:
o   int : 2 Bytes
o   long: 4 Bytes
o   float: 4 Bytes
o   double: 8 Bytes
o   long double: 10 Bytes
o   char : 1 Byte
o   array : <the data type storage size * array size> Bytes
for example,
char arr[30] then (1*30= 30 Bytes )
int arr[10] then (2*10=20 Bytes)  
·         Though Private members of class are not inherited, they are present in the derived class but not accessible. That is why when we calculate the size of any class, we add up the sizes of private data members of base class also.         
·         Inheritance is of 5 types. Remember the Word MHS. Mfor Multiple Inheritance and Multilevel Inheritance. Hfor Hierarchical Inheritance and Hybrid Inheritance. Sfor Single Inheritance.

Multilevel Inheritance

 

Hybrid Inheritance

 

Single Multiple and Hierarchical Inheritance 

 

Comments

Popular Posts