Polymorphism means that some code or operations or objects behave differently in different contexts.
class Shapeofangles {
protected:
height, width;
public:
Shape( int x=0, int y=0)
{
width = x;
height = y;
}
int area()
{
cout << "Parent class area :" <<endl;
return 0;
}
};
class Rectangle: public Shapeofangles{
public:
Rectangle( int c=0, int d=0)
{
Shape(c, d);
}
int area ()
{
cout << "Rectangle class area :" <<endl;
return (width * height);
}
};
class Triangle: public Shapeofangle{
public:
Triangle( int a=0, int b=0)
{
Shape(a, ;
}
int area ()
{
cout << "Rectangle class area :" <<endl;
return (width * height / 2);
}
};
Mobile website designer
Website designer los angeles
This post has been edited by David Acer: Feb 19 2013, 09:05 AM