header file

Hi all, i just joined here. I appreciate if you could help me debug my code.
i am using dev-c++ and created the following files just to see how to work with header and cpp files:
Mammal.h
Mammal.cpp
main.cpp

But the compiler yells "[Linker error] undefined reference to `Mammal::Mammal()'" :(

the codes are as follows:
Mammal.h code:

#ifndef Mammal_H_
#define Mammal_H_
class Mammal
{
public:
// constructors
Mammal();
~Mammal();
private:
int itsAge;
int itsWeight;
};
#endif


Mammal.cpp code:

#include <iostream.h>
#include "Mammal.h"

Mammal::Mammal():itsAge(2), itsWeight(5)
{
}

Mammal::~Mammal()
{
}

main.cpp code:

#include <iostream.h>
#include "Mammal.h"


int main()
{
Mammal dog;
system("PAUSE");
return 0;
}
In main, try Mammal::Mammal dog;
Add Mammal.cpp to your project. Just having it open in the editor isn't enough.
Thank you cire. The problem was that I had not added them as a project.
Topic archived. No new replies allowed.