Skip to main content
gamedev.net
🔒 Locked

class unidentified

Started by BloodLust666 Aug 24, 2005 at 7:40 PM 5 replies 500+ views
Original Post
BloodLust666
BloodLust666
i have 4 classes. one is the main one that has a template of the other 3 in them class one { vector asdf2; vector asdf3; vector asdf4; } BUT in class four, i have a fuction that's static in class one class four { void Something() {m_four + one::GetANumber();}; } but no matter which way i order them when i declare them or whatever, the one at the top says the class in it is unidentified. i even tried to pre-define them all class one; class two; class three; class four; does nothing... any suggestions?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
SiCrane
SiCrane
First try seperating your function definitions into separate files from the class definitions. See this article for details. If that doesn't work, try showing some real code.
Fruny
Fruny
Don't put the body of the function in the class definition. Move it to a CPP file.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
BloodLust666
BloodLust666
but i wanted it inline, or should i just PUT "inline" and have the body in the corresponding .cpp file?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
awesome, that worked, putting the function inline and having the body in the .cpp file :)
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Fruny
Fruny
Quote:
Original post by EvilKnuckles666
awesome, that worked, putting the function inline and having the body in the .cpp file :)


Not going to work. You'll get a linker error if you try to use the function.

You could do this though

class four{  void Something();};class one{  vector<four> f;};inline void four::Something(){  m_four + one::GetANumber();}
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
kusma
kusma
this works...

[cpp]
class four;
class one
{
public
vector asdf4;
static int GetANumber() { return rand(); }
};

class four
{
public:
four() : m_four(0) {}
int Something() {return m_four + one::GetANumber();};
int m_four;
};
[/cpp]

[Edited by - kusma on August 24, 2005 8:18:45 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.