[Cpp]
# Include <iostream>
Using namespace std;
Enum BREED {black, red, white, blue };
Class mam {
Public:
Mam ();
~ Mam ();
Int get_age () const {return age ;}
Void set_age (int age1) {age = age1 ;}
Int get_weight () const {return weight ;}
Void set_weight (int x) {weight = x ;}
Void speak () const {cout <"mam sound! \ N ";}
Void sleep () const {cout <"I 'am sleeping. \ n ";}
Protected:
Int age;
Int weight;
};
Class dog: public mam {
Public:
Dog ();
~ Dog ();
BREED get_breed () const {return its_breed ;}
Void set_breed (BREED breed) {its_breed = breed ;}
Void wag_tail () const {cout <"Tail wagging... \ n ";}
Void beg_for_food () const {cout <"begging for food... \ n ";}
Private:
BREED its_breed;
};
Mam: mam (): age (3), weight (8 ){
Cout <"mam constructor..." <endl;
}
Mam ::~ Mam (){
Cout <"mam destructor..." <endl;
}
Dog: dog (): its_breed (blue ){
Cout <"dog constructor..." <endl;
}
Dog ::~ Dog (){
Cout <"dog destructor..." <endl;
}
Int main ()
{
Dog fido;
Fido. speak ();
Fido. wag_tail ();
Cout <"fido is" <fido. get_age () <"years old" <endl;
// Cout <fido. get_breed () <endl;
// Fido. set_breed (white );
// Cout <fido. get_breed () <endl;
Return 0;
}