I have the following code, and every time I compile, it's giving me an error saying that there is an undefined reference to ns::player::player()
This has never happened to me before, so to be honest, I'm quite confused. I just know it's something simple. By the way, the code below isn't exactly the code I'm working with, but it's the same idea. I just shortened it up and changed the names to make it easier to read.
Also, if I put it all into one file, it plays nice.
main.cpp
#include "space.hpp"
int main()
{
ns::player kyle;
return 0;
}
space.hpp
#ifndef SPACE_HPP_INCLUDED
#define SPACE_HPP_INCLUDED
namespace ns
{
class player
{
private:
int stat1, stat2, stat3;
public:
player();
player(int, int, int);
};
}
#endif
space.cpp
#include "space.hpp"
ns::player::player()
{
stat1 = 100;
stat2 = 200;
stat3 = 300;
}
ns::player::player(int a, int b, int c)
{
stat1 = a;
stat2 = b;
stat3 = c;
}