Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

joepadmiraal

simple class question

This topic is 5218 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 a simple class question/problem. Here is an example of my code:
class a
{
  int someVariable;
  void aFunction(void);
}

class b
{
  int someOtherVariable;
  a classA;
}
I want to create a pointer to class b inside class a. This way the functions from class a can use variables from class b. This piece of code does not work because at the time class a is compiled the compiler does not know class b yet.
class a
{
  int someVariable;
  b classB;
  void aFunction(void);
}
Does anyone know if it is possible and how it''s done?? Thanx!

Share this post


Link to post
Share on other sites
Advertisement

class b;

class a
{
b* ptr;
...
};

class b
{
...
};


Hellsp4wn
-----------

I'm having deja-vu and amnesia at the same time. It's like I think I've forgotten this before.

[edited by - Hellsp4wn on June 7, 2004 4:30:56 PM]

Share this post


Link to post
Share on other sites

  • 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!