in my header file:
private:
struct movieNode {
string title;
castNode *castHead;
movieNode *prev;
movieNode *next;
};
struct castNode {
string name;
castNode *next;
};
movieNode *head;
movieNode *last;
but the compiler error is:
expected ‘;’ before ‘*’ token
my aim is that every movieNode should have a title and a cast list (with castNode).
thanks in advance.
movieNodeneeds to at least be able to see an incomplete type calledcastNode. At the moment, the compiler is going “Huh,castNode? What the hell is that?” because it hasn’t seen the definition ofcastNodeyet. You can avoid it in this case by simply definingcastNodebefore you definemovieNode. Just swap the two structs around.In other cases, where you have a cyclic dependency (if
castNodehad a pointer to amovieNodetoo, for example), you can use a forward declaration to provide an incomplete type (it would look likeclass castNode;) and then define it properly later.