forked from grantrostig/cpp_by_example
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
25 lines (20 loc) · 516 Bytes
/
main.cpp
File metadata and controls
25 lines (20 loc) · 516 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// this example explores forward declarations of classes, not just functions, which is what most blog posts cover.
#include "c.h"
#include "d.h"
struct B;
struct A {
B * a3; // this works because it is a pointer and doesn't need to know the full structure of the object pointed too.
B a2; // todo: Is it possible to make this work? // ERROR: field has incomplete type 'B'
};
struct B {
// A b2 {};
int i;
};
int main()
{
A my_a;
B my_b;
C my_c;
D my_d;
return 0;
}