

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Html php javascript mysql wamp server
Typology: Lecture notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Previous Page Next Page
class Box { public: // pure virtual function virtual double getVolume() = 0; private: double length; // Length of a box double breadth; // Breadth of a box double height; // Height of a box };
Live Demo #include using namespace std; // Base class class Shape { public: // pure virtual function providing interface framework. virtual int getArea() = 0 ; void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } protected: int width; int height; }; // Derived classes class Rectangle: public Shape { public: int getArea() { return (width * height); } }; class Triangle: public Shape { public: int getArea() { return (width * height)/ 2 ; } }; int main(void) { Rectangle Rect; Triangle Tri;