Hello DaniWeb, its been a long time! Anyway, I'm trying to put classes and functions inside .h files and define them in respective .cpp files. Whenever I try this, I get a weird error that I think has something to do with my constructor:
obj\Debug\main.o||In function `_static_initialization_and_destruction_0': |
main.cpp|33|undefined reference to `Character::Character()'|
I am on 64bit Windows 7, using CodeBlocks IDE.
Here is my "character.h"
#ifndef CHARACTER_H
#define CHARACTER_H
#include <iostream>
#include <string>
#include <vector>
class Character{
public:
Character(); // constructor
int health;
int magic;
int level;
int eyeColor;
std::vector<std::string> inventory;
std::vector<std::string> abilities;
};
#endif
Here is my "character.cpp"
#include "character.h"
Character::Character(){
inventory.push_back("SWORD");
inventory.push_back("SHIELD");
abilities.push_back("ATTACK");
eyeColor = 1;
health = 100;
magic = 50;
level = 1;
}
And here is my main.cpp
#include <iostream>
#include "character.h"
int main(){
Character mainCharacter;
std::cout << mainCharacter.health;
return 0;
}
Thanks!