Hi I'm slightly new with programming and I'm getting an undefined error.
I have a main.cpp source file, and soldier.h header file, and a soldier.cpp source file. I declared some functions in the header file and defined them in the soldier.cpp file. When I call them in main.cpp, they don't run and I get an error "undefined reference". When I know that I defined them! Here is the code for my header file
#include <iostream>
usingnamespace std;
class Soldier
{
public:
Soldier(int x, int y);
void attack();
void heal( int z);
void beAttacked();
int getHealth();
private:
int health;
int strength;
};
I have no idea what happened but I just recreated the files and pasted their code back in and it would work. What I noticed was the problem was the actual header file and soldier source file wouldn't build or tell you any errors. I fixed it. thanks.