Polymorphism
Polymorphism
Polymorphism:
It means one mean having multiple forms. These are two types of polymorphism,namely,compile time and run time polymorphism.
Polymorphism
Function overloading
Operator overloading
Virtual Function
Object Pointer are useful in creating objects at runtime.It can be used to access the publc menbers of an objects,along with an arrow operator.
UNIT-2
Virtual Functions:
When a function is made virtual,c++ determines which function to use at run time based on the type of object pointed to by the base pointer,rather than the type of the pointer. Syntax: Virtual returntype fun_name(arg list) {.}
UNIT-2
class Base { public: void display() { cout<<\n Display Base; } virtual void show() { cout<<\nShow Base: } } class Derived : public Base { public: void display() { cout<<\n Display Derived:; } virtual void show() { cout<<\n Show Derived:; } }; int main( ) { Base B; Derived D; Base *bptr; // pointer to object cout<<\n bptr points to Base; bptr=&B; bptrdisplay(); bptrshow(); cout<<\n bptr points to Derived; bptr=&D; bptrdisplay(); bptrshow(); return 1; }