Semester : SEMESTER 6
Subject : Object Oriented Programming
Year : 2018
Term : MARCH
Scheme : 2015 Full Time
Course Code : EC 312
Page:9
using namespace std;
// Base class
class Shape {
public:
void setWidth(int w) {
width = w;
}
void setHeight(int h) {
height = h;
protected:
int width;
int height;
35
// Derived class
class Rectangle: public Shape {
public:
int getArea() {
return (width * height);
35
int main(void) {
Rectangle Rect;
Rect.setWidth(5);
Rect.setHeight(7);