Original Post
Hi, im kinda new to C++, I just read some guides and books... im trying out constructors, as I want to create an online game later on, and I want to create the enemies quickly. This is the code Im having some trouble with: #include #include using namespace std; class gEnemy { public: unsigned int wspd; // The walking speed of an enemy unsigned int atk; // The attack power of an enemy unsigned int def; // The defense rate of an enemy unsigned int aspd; // The attack speed of an enemy unsigned int hp; // The amount of health points of enemy unsigned int lvl; // The level the monster is at char name[20]; // the name of the monster gEnemy(char *str, int wspd, int atk, int def, int aspd, int hp, int lvl) //monsters constructor { strcpy_s(name, str); } void showInfo() { cout << name << " has " << wspd << " walking speed, " << atk << " attack power,\n" << def << " defense, " << aspd << " attack speed, " << hp << " health points and is Lv " << lvl << "\n\n"; } }; int main() { gEnemy Monster1("Monster1", 5, 10000, 50000, 75, 20000, 111); gEnemy Monster2("Monster2", 3, 10000, 75000, 40, 40000, 111); Monster1.showInfo(); Monster2.showInfo(); system("PAUSE"); return 0; }; The problem with this is that all the values seems to be set to 3435973836 when I run the program, with both the monsters, even though I wrote other values in contructing... Why dont they get the right value? Do I use too many paramenters, any code errors? It compiles perfectly though... Help please :D