What is Inheritance  Polymorphism  is the ability to use an operator or function in different ways. Polymorphism gives dif...
Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator ...
#include <iostream> using namespace std; class CPolygon {     protected:       int width, height;     public:       void s...
class CTriangle: public CPolygon {     public:       int area ()         {         return (width * height / 2);         } ...
Int main () {     CRectangle rect;     CTriangle trgl;     CPolygon * ppoly1 = &rect;     CPolygon * ppoly2 = &trgl;     p...
Get more programming tutorial www.cprogrammings.com
Upcoming SlideShare
Loading in …5
×

Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt | Polymorphism in c++ ppt presentation

12,130 views

Published on

Learn about What is polymorphism in c++ , Polymorphism in c++ with example , Types of polymorphism in c++ and for more visit www.cprogrammings.com

Published in: Education, Technology, Business
2 Comments
3 Likes
Statistics
Notes
  • ok
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • convert it to pdf or any word document forms..so tat we can read it wenever we want.we may not be using facebook or our email always
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
12,130
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
393
Comments
2
Likes
3
Embeds 0
No embeds

No notes for slide

Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt | Polymorphism in c++ ppt presentation

  1. 2. What is Inheritance  Polymorphism  is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions.
  2. 3. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
  3. 4. #include <iostream> using namespace std; class CPolygon {     protected:       int width, height;     public:       void set_values (int a, int b)         { width=a; height=b; } };     class CRectangle: public CPolygon {     public:       int area ()         { return (width * height); }     };     Example of Inheritance 
  4. 5. class CTriangle: public CPolygon {     public:       int area ()         {         return (width * height / 2);         } };    
  5. 6. Int main () {     CRectangle rect;     CTriangle trgl;     CPolygon * ppoly1 = &rect;     CPolygon * ppoly2 = &trgl;     ppoly1->set_values (4,5);     ppoly2->set_values (4,5);     cout << rect.area() << endl;     cout << trgl.area() << endl;     return 0;   }
  6. 7. Get more programming tutorial www.cprogrammings.com

×