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;
}