t0by
April 10th, 2003, 01:23 PM
Hello all. I would be extremely glad if someone could guide me to the right path:
I learning c++ polymorfism mechanisms, and these
errors give me trouble:
bird.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
owl.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
parrot.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
Classes that I have (and I use inheritance in them):
Animal
Bird
Owl
Parrot
Is there a mismatch between the functions I implement and the inheritance mechanism (with virtual functions or something)?
I list the functions I implement in .cpp files below, and under them the .h files.
//animal.cpp
Animal::Animal(char *name, float mass, float energy)
Animal::~Animal()
void Animal::eat(float food)
char* Animal::getName()
float Animal::move(float distance)
//bird.cpp
Bird::Bird(char *name, float mass, float energy, float wingspan) : Animal(name,mass,energy)
void Bird::lay()
float Bird::move(float distance)
void Bird::say(const char *sentence)
//parrot.cpp
Parrot::Parrot(char *name, float mass, float energy, float wingspan) : Bird(name,mass,energy,wingspan)
void Parrot::say(const char *sentence)
Parrot::~Parrot()
//owl.cpp
Owl::Owl(char *name, float mass, float energy, float wingspan) : Bird(name,mass,energy,wingspan)
void Owl::say(const char *sentence)
I list my definitions below:
//Animal.h
class Animal {
Animal(char *name=NULL, float mass=1.0, float energy=0.0);
virtual ~Animal();
void eat(float food);
char *getName();
protected:
char *name; /**<- name of the animal */
float mass; /**<- mass in kilograms */
float energy; /**<- energy in joules */
};
//bird.h
class Bird : public Animal {
public:
Bird(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual void say(const char *sentence);
virtual void lay();
virtual ~Bird();
virtual float move(float distance);
protected:
float wingspan; /**<- wingspan of the bird */
};
//parrot.h
class Parrot : public Bird {
public:
Parrot(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual ~Parrot();
virtual void say(const char *sentence);
char *previousSentence;
};
//owl.h
class Owl : public Bird {
public:
Owl(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual void say(const char *sentence);
};
I learning c++ polymorfism mechanisms, and these
errors give me trouble:
bird.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
owl.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
parrot.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Bird::~Bird(void)" (??1Bird@@UAE@XZ)
Classes that I have (and I use inheritance in them):
Animal
Bird
Owl
Parrot
Is there a mismatch between the functions I implement and the inheritance mechanism (with virtual functions or something)?
I list the functions I implement in .cpp files below, and under them the .h files.
//animal.cpp
Animal::Animal(char *name, float mass, float energy)
Animal::~Animal()
void Animal::eat(float food)
char* Animal::getName()
float Animal::move(float distance)
//bird.cpp
Bird::Bird(char *name, float mass, float energy, float wingspan) : Animal(name,mass,energy)
void Bird::lay()
float Bird::move(float distance)
void Bird::say(const char *sentence)
//parrot.cpp
Parrot::Parrot(char *name, float mass, float energy, float wingspan) : Bird(name,mass,energy,wingspan)
void Parrot::say(const char *sentence)
Parrot::~Parrot()
//owl.cpp
Owl::Owl(char *name, float mass, float energy, float wingspan) : Bird(name,mass,energy,wingspan)
void Owl::say(const char *sentence)
I list my definitions below:
//Animal.h
class Animal {
Animal(char *name=NULL, float mass=1.0, float energy=0.0);
virtual ~Animal();
void eat(float food);
char *getName();
protected:
char *name; /**<- name of the animal */
float mass; /**<- mass in kilograms */
float energy; /**<- energy in joules */
};
//bird.h
class Bird : public Animal {
public:
Bird(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual void say(const char *sentence);
virtual void lay();
virtual ~Bird();
virtual float move(float distance);
protected:
float wingspan; /**<- wingspan of the bird */
};
//parrot.h
class Parrot : public Bird {
public:
Parrot(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual ~Parrot();
virtual void say(const char *sentence);
char *previousSentence;
};
//owl.h
class Owl : public Bird {
public:
Owl(char *name=NULL, float mass=1.0, float energy=0.0, float wingspan=1.0);
virtual void say(const char *sentence);
};