Object oriented programming language
SAADIA BANO
Lecturer
[email protected]
COMSATS Institute of Information Technology
Department of Computer Science,
Sahiwal
Function overriding
Function Overloading is when multiple function with same name exist in a
class. Function Overriding is when function have same prototype in base
class as well as derived class.
Function Overloading can occur without inheritance. Function
Overriding occurs when one class is inherited from another class
Example
Example
Example
Types of inheritance
Public inheritance
Syntax: class child:public parent
Private inheritance
Syntax: class child: private parent
Protected inheritance
Syntax: class child:protected parent
How to access protected member of
parent class
Container-ship
Class contains object of another class as its member
This is also known as has-a-relationship
Example:
Class A
{
};
Class B
{
A obj;
};
Example