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.
More Related Contents:
- Resolve build errors due to circular dependency amongst classes
- When can I use a forward declaration?
- What are forward declarations in C++?
- Forward declaration of nested types/classes in C++
- How do I forward declare an inner class? [duplicate]
- Forward declaration of a typedef in C++
- Should one use forward declarations instead of includes wherever possible?
- Forward declaration with unique_ptr? [duplicate]
- Circular C++ Header Includes
- error: member access into incomplete type : forward declaration of
- In C++, is it possible to forward declare a class as inheriting from another class?
- What is the header?
- Why, really, deleting an incomplete type is undefined behaviour?
- What is forward declaration in c++? [duplicate]
- C++ class forward declaration
- Pros & Cons of putting all code in Header files in C++?
- Why does a C++ friend class need a forward declaration only in other namespaces?
- Why must an enumeration’s size be provided when it is forward declared?
- Forward declaration & circular dependency
- What is the purpose of forward declaration?
- Forward Declaration of variables/classes in std namespace
- C++ Circular Dependency in Header Files
- Recursion in c++ Factorial Program
- Qt “private slots:” what is this?
- How to initialize static members in the header
- Why Can’t I store references in a `std::map` in C++?
- How can adding code to a loop make it faster?
- Add elements to a vector during range-based loop c++11
- how to use gpu::Stream in OpenCV?
- Show two digits after decimal point in c++ [duplicate]