How would I implement an aggregation relationship with the possibility to navigate from a child object to its parent object?
Do I need to use forward declaration?
How would I implement an aggregation relationship with the possibility to navigate from a child object to its parent object?
Do I need to use forward declaration?
Yes you do.
struct Node;
struct Aggregator {
Node* parent;
Node aggregated1, aggregated2;
};
struct Node {
Aggregator* aggregated_by;
};
Though with nested types you might be able to dodge it, or if the parent has the same type:
struct Node {
Node* parent;
Node aggregated1, aggregated2;
};