C++ examples for Class:Inheritance
To create a class that inherits from another class
#include <iostream> /*from w w w . ja va 2s . c om*/ enum COLOR { RED, BLUE, WHITE, BLACK, EE, YELLOW }; class Pet { public: // constructors Pet(); ~Pet(); // accessors int getAge() const; void setAge(int); int getWeight() const; void setWeight(); // other member functions void speak(); void sleep(); protected: int age; int weight; }; class Dog : public Pet { public: // constructors Dog(); ~Dog(); // accessors COLOR getBreed() const; void setBreed(COLOR); // other member functions // wagTail(); // begForFood(); protected: COLOR itsBreed; }; int main() { return 0; }