Skip to main content
gamedev.net
🔒 Locked

simple class question

Started by joepadmiraal 1 reply 250+ views
Original Post
joepadmiraal
joepadmiraal
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!
Hellsp4wn
Hellsp4wn

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]
joepadmiraal
joepadmiraal
Wow..
It''s that simple
(feeling kinda dumb right now)
I tested it and it works
Thanx for helping me out so quick!

Topic Locked

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

Sign in to reply to this topic.