MONSTER* MonsterMasterList(int number);
{ // Error occurs here
MONSTER monsterlist[7];
monsterlist[0].CreateMonster("Wolf Cub",8,0,1,3,5,0,2,1,0,0,0,0,0,9,false,0);
monsterlist[1].CreateMonster("Highwayman",10,0,3,2,5,0,2,2,0,0,0,0,0,9,false,0);
monsterlist[2].CreateMonster("Ochanon",20,5,1,3,9,1,5,8,0,0,0,1,0,9,false,2);
monsterlist[3].CreateMonster("Earth Spirit",5,20,0,1,20,3,20,20,3,0,0,4,50,3,false,1);
monsterlist[4].CreateMonster("Wild Horse",15,0,3,8,5,0,10,7,0,0,0,0,0,9,false,0);
monsterlist[5].CreateMonster("Bear",20,0,5,8,1,0,3,5,0,0,0,0,0,9,false,0);
monsterlist[6].CreateMonster("Imperial Soldier",15,0,6,10,5,0,20,10,0,0,0,0,0,9,false,0);
return(&monsterlist[number]);
}
C++ "Missing function header?"
I'm unsure what this error is or how to fix it
error C2447: '{' : missing function header (old-style formal list?)
Thats the source code for it. Any help will be greatly appreciated.
Well, for one your code wouldn't work even if it compiled.
You are returning the address of a local variable, and because of scoping the variable will be destroyed on leaving the function.
If you were to make MONSTER monsterlist[7]; into static MONSTER monsterlist[7]; then it might work...
Also, you have a semicolon at the end of the function signature
You are returning the address of a local variable, and because of scoping the variable will be destroyed on leaving the function.
If you were to make MONSTER monsterlist[7]; into static MONSTER monsterlist[7]; then it might work...
Also, you have a semicolon at the end of the function signature
MONSTER* MonsterMasterList(int number); // < --- here{
If you havent fixed this problem yet:
In the error it has : '{' meaning something is going on with that character.
Your function should, as suggested drop the ';' at the end of the functions declaration line.
And also when the other guys was talking about return &whatever, whatever gets deleted as soon as the function goes out of scope (when your program is done executing the function), so you are giving the address of something that doesnt exist anymore :)
In the error it has : '{' meaning something is going on with that character.
Your function should, as suggested drop the ';' at the end of the functions declaration line.
And also when the other guys was talking about return &whatever, whatever gets deleted as soon as the function goes out of scope (when your program is done executing the function), so you are giving the address of something that doesnt exist anymore :)
Try to compile this Iccarus
MONSTER* MonsterMasterList(int number){ // Error occurs hereMONSTER monsterlist[7];monsterlist[0].CreateMonster("Wolf Cub",8,0,1,3,5,0,2,1,0,0,0,0,0,9,false,0);monsterlist[1].CreateMonster("Highwayman",10,0,3,2,5,0,2,2,0,0,0,0,0,9,false,0);monsterlist[2].CreateMonster("Ochanon",20,5,1,3,9,1,5,8,0,0,0,1,0,9,false,2);monsterlist[3].CreateMonster("Earth Spirit",5,20,0,1,20,3,20,20,3,0,0,4,50,3,false,1); monsterlist[4].CreateMonster("Wild Horse",15,0,3,8,5,0,10,7,0,0,0,0,0,9,false,0); monsterlist[5].CreateMonster("Bear",20,0,5,8,1,0,3,5,0,0,0,0,0,9,false,0);monsterlist[6].CreateMonster("Imperial Soldier",15,0,6,10,5,0,20,10,0,0,0,0,0,9,false,0);return(&monsterlist[number]);}
This has been said twice already, but I'm going to repeat it because it's so darn important:
Returning the address of a local variable =
Returning the address of a local variable =
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement