1234567891011121314151617181920212223242526272829303132
#include<iostream> class Shape { public: Shape(){} virtual ~Shape(){} }; class Rectangle : public Shape { public: Rectangle(int length=5, int width):Shape(){} ~Rectangle(){} int getLength(){return length;} protected: int length, width; }; class Square : public Rectangle { public: Square(int length):Rectangle(length,length){} virtual Square(const Square & other):Rectangle(other.length, other.length){} ~Square(){} }; int main() { Square Object(); std::cout << "The length is << " <<Object.getLength()<<std::endl; }