G.KARTHIGA
M.SC(INFO TECH)
DEPARTMENT OF CS & IT
NADAR SARSWATHI COLLEGE OF ARTS & SCIENCE ,
THENI.
 The concept of polymorphism is implemented using the
overloaded function and operator.
 The overloaded member function are selected for
invoking by matching arguments both type and number.
 It is called binding or static binding or static linking.
 Member function could be selected while the program
is run time is known as runtime polymorphism
polymorphism
Compile time
polymorphis
m
Runtime
polymorphis
m
Function
overloading
Operator
overloading
Virtual
function
 Pointer is one of the key aspects of C++ language
similar to that of C.
 Pointer is derived data type that refers to another data
variable by storing the variable memory address rather
than data.
 A pointer variable defines to get the value of a specific
data variable of defining actual data.
……. ….. 100 …. 1024 ….
Memory address
1020 1024 1032
integer
pointer
 The declaration of a pointer variable following form:
Example:
int *ptr;
Initialize a pointer:
int *ptr, a;
ptr=&a;
Data _type *pointer –
variable;
To manipulate a pointer with the indirect
operator “*” is known as dereference
operator
*pointer _variable
C++ allows pointers to perform the following arithmetic
operation:
1) A pointer can be incremented (++) or decremented (--).
2) Any integer can be added to subtracted from a pointer.
3) One pointer can be subtracted from another.
Example:
Int *aptr;
Ptr=&a[0];
The array of pointer represents a collection of
address.
An array of pointer point to an array of data
items.
Example:
int *in array[10];
A[2]
A[1]
A[1]
A[3]
A[4]
1000
1004
1008
1012
1016
a
a
The usage of pointer with one dimensional
array element.
A string is one dimensional array of character.
Example:
char num[]=“one”;
const char *numptr=“one”;
 The concept of pointer to function acts as a base for
pointer to member.
 Its known as callback function.
 These function pointer to refer to a function.
Declaration :
Example:
int (* num_function(int x));
data _type (* function_name) ();
To access the class member.
To point to an object created by a class.
Define a pointer:
Item *it_ptr;
This is a pointer that point to the object for
which this function was called.
The pointer this acts as an implict argument to
all the member function.
Example:
Class ABC
{
int a;
…..
};
Pointer to object of a class are type –
compatible with pointer to object of a derived
class.
Pointer is object of derived class.
B *cptr; // pointer to class B type
variable
B b;// base object
D d;// derived object
Cptr=&b;// cptr points to object

Pointer and polymorphism

  • 1.
    G.KARTHIGA M.SC(INFO TECH) DEPARTMENT OFCS & IT NADAR SARSWATHI COLLEGE OF ARTS & SCIENCE , THENI.
  • 2.
     The conceptof polymorphism is implemented using the overloaded function and operator.  The overloaded member function are selected for invoking by matching arguments both type and number.  It is called binding or static binding or static linking.  Member function could be selected while the program is run time is known as runtime polymorphism
  • 3.
  • 4.
     Pointer isone of the key aspects of C++ language similar to that of C.  Pointer is derived data type that refers to another data variable by storing the variable memory address rather than data.  A pointer variable defines to get the value of a specific data variable of defining actual data.
  • 5.
    ……. ….. 100…. 1024 …. Memory address 1020 1024 1032 integer pointer
  • 6.
     The declarationof a pointer variable following form: Example: int *ptr; Initialize a pointer: int *ptr, a; ptr=&a; Data _type *pointer – variable;
  • 7.
    To manipulate apointer with the indirect operator “*” is known as dereference operator *pointer _variable
  • 8.
    C++ allows pointersto perform the following arithmetic operation: 1) A pointer can be incremented (++) or decremented (--). 2) Any integer can be added to subtracted from a pointer. 3) One pointer can be subtracted from another. Example: Int *aptr; Ptr=&a[0];
  • 9.
    The array ofpointer represents a collection of address. An array of pointer point to an array of data items. Example: int *in array[10];
  • 10.
  • 11.
    The usage ofpointer with one dimensional array element. A string is one dimensional array of character. Example: char num[]=“one”; const char *numptr=“one”;
  • 12.
     The conceptof pointer to function acts as a base for pointer to member.  Its known as callback function.  These function pointer to refer to a function. Declaration : Example: int (* num_function(int x)); data _type (* function_name) ();
  • 13.
    To access theclass member. To point to an object created by a class. Define a pointer: Item *it_ptr;
  • 14.
    This is apointer that point to the object for which this function was called. The pointer this acts as an implict argument to all the member function. Example: Class ABC { int a; ….. };
  • 15.
    Pointer to objectof a class are type – compatible with pointer to object of a derived class. Pointer is object of derived class. B *cptr; // pointer to class B type variable B b;// base object D d;// derived object Cptr=&b;// cptr points to object