< previous page page_257 next page >

Page 257
LISTING 16.4 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
22:      void Sleep() const { cout << shhh. I'm sleeping.\n; }
23:
24:
25:   protected:
26:      int itsAge;
27:      int itsWeight;
28:   };
29:
30:   class Dog : public Mammal
31:   {
32:   public:
33:
34:      // Constructors
35:      Dog();
36:      Dog(int age);
37:      Dog(int age, int weight);
38:      Dog(int age, BREED breed);
39:      Dog(int age, int weight, BREED breed);
40:      ~Dog();
41:
42:      // Accessors
43:      BREED GetBreed() const { return itsBreed; }
44:      void SetBreed(BREED breed) { itsBreed = breed; }
45:
46:      // Other methods
47:      void WagTail()const { cout << Tail wagging\n; }
48:      void BegForFood()const { cout << Begging for food\n; }
49:
50:   private:
51:      BREED itsBreed;
52:   };
53:
54:   Mammal::Mammal():
55:   itsAge(1),
56:   itsWeight(5)
57:   {
58:      cout << Mammal constructor\n;
59:   }
60:
61:   Mammal::Mammal(int age):
62:   itsAge(age),
63:   itsWeight(5)
64:   {
65:      cout << Mammal(int) constructor\n;
66:   }
67:
68:   Mammal::~Mammal()
69:   {
70:      cout << Mammal destructor\n;
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
continues

 
< previous page page_257 next page >

If you like this book, buy it!