forward declaration with vector of class type – pointer to incomplete class type not allowed

You can’t forward declare members.

Instead, bar.cpp should #include both foo.h and bar.h. Problem solved.

In general, if you use the sequence:

  • Forward declare all class types
  • Define all class types
  • Bodies of class members

everything will be fine.

Leave a Comment