// polygon3b.cc #include #include using namespace std; class Polygon { private: int NumSides; // outsiders shouldn't be able to change this public: void Draw(void) { cout << "Drawing polygon with " << NumSides << " sides." << endl; } Polygon(int sides) { NumSides = sides; cout << "In Polygon constructor with " << NumSides << " sides" << endl; } }; class Triangle: public Polygon { public: Triangle(): Polygon(3) { // Call base class constructor with required args cout << "In Triangle constructor" << endl; } void Report(void) { cout << "I'm a triangle, I have " << NumSides << " sides." << endl; } }; int main() { Triangle MyTriangle; MyTriangle.Report(); }