C++ Lec1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

A friend function can be used to access the private and protected members in common.

Just by attaching initial friend the function becomes common to both the classes.

Using a friend function the created objects for both the classes can be accessed easily.

To access using friend function an object of the class has to be always defined this obj I called with
the private no. that is need to be accessed.

Inheritance:

It is the property of c++ programming in which members of derived class tend to acquire the function
present in the parent class.

Normally the base class is taken as the umbrella class for disseminating the features that are
common for one or more derived/child classes.

It can be divided broadly into 2 categories :

1. Single inheritance-in this there is one base class and one derived child/derived class.

A
a
2. Multiple inheritance-Multiple inheritance there is one base class but there may be multiple
derived class.

A
a b c
3. There is another type of inheritance, i.e. multi-level inheritance the advantage of multilevel
is that the feature can be shared easily.

(NOTE: private members are exclusive to a particular class, public members are accesible
throughout the program, protected members have an advantage, that the members of the
parent class can by deafult be accessed by the derived classes.)

You might also like