Chapter_5_Polymorphism
Chapter_5_Polymorphism
in C++
(CMP 115)
Chapter-5: Polymorphism
Er. Nirmal Thapa
Email: [email protected]
Lumbini Engineering College
Pokhara University
This pointer
• To understand ‘this’ pointer, it is important to know how objects look at functions and data
members of a class.
• Each object gets its own copy of the data member.
• All-access the same function definition as present in the code segment
• The ‘this’ pointer is passed as a hidden argument to all member function calls and is available as
a local variable within the body of all non-static functions.
• this pointer is used to represent the address of an object inside a member function.
Defining in a base class a virtual function, with another version in a derived class,
signals to the compiler that we don't want static linkage for this function.
The function to be called at any given point in the program to be based on the kind of
object for which it is called.