B
Brian C
Hello all,
I have, what I'm sure is an idiotic question, but I can't seem to find
an answer for it (probably looking in the wrong direction of course).
I'm coming from numerous years in C programming, trying to expand my
horizons and get into C++.
I did a little bit of Java programming along my C days, and this
problem was solved with getParent(), which doesn't pertain to C++ I've read.
So, if I have this:
......(file: A.h).....
#ifndef __A_H
#define __A_H
#include "b.h"
class A
{
public:
...
private:
B *ClassBPtr;
};
#endif
.....(file: B.h).....
#ifndef __B_H
#define __B_H
#include "a.h"
class B
{
public:
...
private:
A *ClassAPtr;
};
#endif
I of course get an error on compiling because when compiling "b.h", it
cannot figure out what class "A" is.
The basic idea is that, lets say class B is a thread running
independently of the class A instance. Some data comes in, and it needs
to feed it to class A. I know it's not a perfect example, but it's
probably the simplest I can come up with right now.
I know that I could do a nested class with class B inside of class A,
but what if I need to use class B somewhere else?
Thanks in advance.
I have, what I'm sure is an idiotic question, but I can't seem to find
an answer for it (probably looking in the wrong direction of course).
I'm coming from numerous years in C programming, trying to expand my
horizons and get into C++.
I did a little bit of Java programming along my C days, and this
problem was solved with getParent(), which doesn't pertain to C++ I've read.
So, if I have this:
......(file: A.h).....
#ifndef __A_H
#define __A_H
#include "b.h"
class A
{
public:
...
private:
B *ClassBPtr;
};
#endif
.....(file: B.h).....
#ifndef __B_H
#define __B_H
#include "a.h"
class B
{
public:
...
private:
A *ClassAPtr;
};
#endif
I of course get an error on compiling because when compiling "b.h", it
cannot figure out what class "A" is.
The basic idea is that, lets say class B is a thread running
independently of the class A instance. Some data comes in, and it needs
to feed it to class A. I know it's not a perfect example, but it's
probably the simplest I can come up with right now.
I know that I could do a nested class with class B inside of class A,
but what if I need to use class B somewhere else?
Thanks in advance.