Okay..
I have and object named Enemy_1. I need 5 of these objects. So I created five:
Code:
Enemy_1 *Enemy[1] = new Enemy_1;
Enemy_1 *Enemy[2]= new Enemy_1;
Enemy_1 *Enemy[3]= new Enemy_1;
Enemy_1 *Enemy[4]= new Enemy_1;
Enemy_1 *Enemy[5]= new Enemy_1;
and then externed them
Code:
extern Enemy_1 *Enemy[1];
extern Enemy_1 *Enemy[2];
extern Enemy_1 *Enemy[3];
extern Enemy_1 *Enemy[4];
extern Enemy_1 *Enemy[5];
Then assign various values to them using a for loop like so:
Code:
for(i=1;i<6;i++)
{
Enemy[i]->Enemy1_Sprite->Picture->LoadFromFile("ship-5.bmp");
}
And boy does the compiler not like em!(Borland c++ Builder 6, win xp)
these are the errors i get:
With the extern part:
Code:
[C++ Error] Global_Var.h(6): E2356 Type mismatch in redeclaration of 'Enemy'
[C++ Error] Global_Var.h(5): E2344 Earlier declaration of 'Enemy'
[C++ Error] Global_Var.h(7): E2356 Type mismatch in redeclaration of 'Enemy'
[C++ Error] Global_Var.h(5): E2344 Earlier declaration of 'Enemy'
[C++ Error] Global_Var.h(8): E2356 Type mismatch in redeclaration of 'Enemy'
[C++ Error] Global_Var.h(5): E2344 Earlier declaration of 'Enemy'
[C++ Error] Global_Var.h(9): E2356 Type mismatch in redeclaration of 'Enemy'
[C++ Error] Global_Var.h(5): E2344 Earlier declaration of 'Enemy'
With the declare part
Code:
[C++ Error] Lvl1.h(15): E2034 Cannot convert 'Enemy_1 *' to 'Enemy_1 *[1]'
[C++ Error] Lvl1.h(16): E2238 Multiple declaration for 'Enemy'
[C++ Error] Lvl1.h(15): E2344 Earlier declaration of 'Enemy'
[C++ Error] Lvl1.h(16): E2034 Cannot convert 'Enemy_1 *' to 'Enemy_1 *[2]'
[C++ Error] Lvl1.h(17): E2238 Multiple declaration for 'Enemy'
[C++ Error] Lvl1.h(16): E2344 Earlier declaration of 'Enemy'
[C++ Error] Lvl1.h(17): E2034 Cannot convert 'Enemy_1 *' to 'Enemy_1 *[3]'
[C++ Error] Lvl1.h(18): E2238 Multiple declaration for 'Enemy'
[C++ Error] Lvl1.h(17): E2344 Earlier declaration of 'Enemy'
[C++ Error] Lvl1.h(18): E2034 Cannot convert 'Enemy_1 *' to 'Enemy_1 *[4]'
[C++ Error] Lvl1.h(19): E2238 Multiple declaration for 'Enemy'
[C++ Error] Lvl1.h(18): E2344 Earlier declaration of 'Enemy'
[C++ Error] Lvl1.h(19): E2034 Cannot convert 'Enemy_1 *' to 'Enemy_1 *[5]'
and where I try to use them:
Code:
[C++ Warning] Lvl1.h(35): W8004 'Enemy' is assigned a value that is never used
[C++ Warning] Lvl1.h(35): W8004 'Enemy' is assigned a value that is never used
[C++ Warning] Lvl1.h(35): W8004 'Enemy' is assigned a value that is never used
[C++ Warning] Lvl1.h(35): W8004 'Enemy' is assigned a value that is never used
THanks for the help
Cheers