help with C++, QUICK!!!

Started by
4 comments, last by The Alchemist 23 years, 8 months ago
guys thre something wrong in this class declaration?
    
class Layer{
	bool cpu;
	int limit;
public:
	bool alive;
	unsigned int index;
==>	Fighter *registr[10];
	int  AddFighter(char name[11]);
	DeleteFighter();
	DeleteAll();
	Layer();
    virtual ~Layer();
};
    
my compiler gives the folow errors: c:\projetos\rpg3\layer.h(27) : error C2143: syntax error : missing '';'' before ''*'' c:\projetos\rpg3\layer.h(27) : error C2501: ''Fighter'' : missing storage-class or type specifiers c:\projetos\rpg3\layer.h(27) : error C2501: ''registr'' : missing storage-class or type specifiers the line 27 is with a ==> in the code. please help me this thing is f***king with my program So. i was there in the middle of a lot of witches and mages, when she come to me: -You are too young to be a mage. -No, i´m not a mage, i´m a programmer. -How! Sorry... what a bad luck. -Yeah... Don´t even talk about it...
"Everything works out in the end, if it doesn't then it is not the end"
Advertisement
I assume that the Fighter class is declared somewhere that this class can get access to the definition, like in a header file.
If not then this class does not know what a Fighter is and craps out.

------------------
Andrew

Edited by - acraig on August 18, 2000 2:01:48 AM
but is that the problem the Fighter class declaretion is included on the files, i use a lot of Fighters class pointers in the other parts of the program but that is the only part that it make a mess, i simply don´t get it

So. i was there in the middle of a lot of witches and mages, when she come to me:
-You are too young to be a mage.
-No, i´m not a mage, i´m a programmer.
-How! Sorry... what a bad luck.
-Yeah... Don´t even talk about it...
"Everything works out in the end, if it doesn't then it is not the end"
quote:Fighter *registr[10];


I think this line needs to be "Fighter (*register)[10];" I don''t remember exactly, but I do remember that you need parenthesis somewhere.

-Jussi
well i don´t think that it is the case since i have another Fighter pointers array in other part of the program, but i gonna try it, thanks

So. i was there in the middle of a lot of witches and mages, when she come to me:
-You are too young to be a mage.
-No, i´m not a mage, i´m a programmer.
-How! Sorry... what a bad luck.
-Yeah... Don´t even talk about it...
"Everything works out in the end, if it doesn't then it is not the end"
It seems to me that the second error is the key. At your line 27, the compiler doesn''t know what Fighter is.

You say it is included, but is it really? I think not. acraig is right. (Could it be effectively removed by compiler directives (e.g., #ifdef...#endif)?)

Since you''re specifying an array of pointers, why not try a forward declaration of the class, like this:

// the following line is added. yes the semicolon must be there
class Fighter;
//
class Layer{
bool cpu;
int limit;
public: bool alive;
unsigned int index;
Fighter *registr[10];
int AddFighter(char name[11]);
DeleteFighter();
DeleteAll();
Layer();
virtual ~Layer();
};

Try that and see what happens.



Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
email: grhodes@sed.ara.com
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement