A
Andrea Crotti
I fell into the forward declaration trap, so I made a small example to
be sure I understood.
Suppose I have
#include <iostream>
#include "A.h"
void A::nothing()
{
std::cout << b->x;
}
int main(int argc, char *argv[])
{
return 0;
}
#ifndef B_H
#define B_H
class B
{
public:
int x;
};
#endif /* B_H */
#ifndef B_H
#define B_H
class B
{
public:
int x;
};
#endif /* B_H */
In A.h I forward declare the class B, but since I have to really use
the pointer it doesn't work.
(incomplete type).
So I guess in those cases I can only include the class that defines
that type (which I wanted to avoid), right?
be sure I understood.
Suppose I have
#include <iostream>
#include "A.h"
void A::nothing()
{
std::cout << b->x;
}
int main(int argc, char *argv[])
{
return 0;
}
#ifndef B_H
#define B_H
class B
{
public:
int x;
};
#endif /* B_H */
#ifndef B_H
#define B_H
class B
{
public:
int x;
};
#endif /* B_H */
In A.h I forward declare the class B, but since I have to really use
the pointer it doesn't work.
(incomplete type).
So I guess in those cases I can only include the class that defines
that type (which I wanted to avoid), right?