Reputation: 184
Sorry if the question title isn't confusing but I'm not sure how to word it better.
Basically, here is my code.
Header File
class Foo {
public:
Foo();
private:
Bar * b;
}
class Bar {
public:
Bar(Foo *f);
private:
Foo * foo;
}
cpp File
Foo::Foo() {
new Bar(this);
}
Bar::Bar(Foo * f) {
foo = f;
}
I am trying to pass the values to each other back and forth but Bar is not declared to Foo. How do I make Bar known to Foo?
Upvotes: 0
Views: 39
Reputation: 54600
class Bar; // <-- Forward declaration.
class Foo {
public:
Foo();
private:
Bar * b;
}
Upvotes: 3