Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

class unidentified

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have 4 classes. one is the main one that has a template of the other 3 in them class one { vector<two> asdf2; vector<three> asdf3; vector<four> 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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Don't put the body of the function in the class definition. Move it to a CPP file.

Share this post


Link to post
Share on other sites
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();
}

Share this post


Link to post
Share on other sites
this works...

[cpp]
class four;
class one
{
public
vector<four> 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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!