Original Post
ok, i am having a bit of a problem executing the destructor in inhertence, i need some feed back! (questions in comments) header file (listing 12-3.h) and for source file, listing 12-3.cpp any help will be greatly apprecated (i can't spell [depressed])!!! [repost]
#include <iostream>
using namespace std;
enum BREED { GOLDEN, CAIRN, DANDIE, SHETLAND, DOBERMAN, LAB };
class Mammal
{
public:
Mammal();
~Mammal();
int GetAge() const { return itsAge; }
void SetAge(int age) { itsAge = age; }
int GetWeight() const { return itsWeight; }
void SetWeight(int weight) { itsWeight = weight; }
void Speak() const { cout << "Mammal sound!\n"; }
void Sleep() const { cout << "shhh. I'm sleeping.\n"; }
protected:
int itsAge;
int itsWeight;
};
class Dog : public Mammal
{
public:
Dog();
~Dog();
BREED GetBreed() const { return itsBreed; }
void SetBreed(BREED breed) { itsBreed = breed; }
void WagTail() const { cout << "Tail wagging...\n"; }
void BegForFood() const { cout << "Begging for food...\n"; }
private:
BREED itsBreed;
};
Mammal::Mammal():
itsAge(1),
itsWeight(5)
{
cout << "Mammal constructor...\n";
}
Dog::Dog():
itsBreed(GOLDEN)
{
cout << "Dog constructor...\n";
}
Mammal::~Mammal() //how do i know this is executed?
{
cout << "Mammal destructor...\n";
}
Dog::~Dog()
{
cout << "Dog destructor...\n";
}
#include "listing 12-3.h"
int main()
{
Dog fido;
fido.Speak();
fido.WagTail();
cout << "Fido is " << fido.GetAge() << " years old\n";
system("PAUSE");
return 0;
}//the destructor does not give me a message, does this mean i messed up?