EDIT: For anyone who finds this question in the future, the following read helped me a lot: http://www.umich.edu/~eecs381/handouts/IncompleteDeclarations.pdf
I have a class whose header file looks approximately like
#ifndef FOO_HPP_
#define FOO_HPP_
#include <memory>
#include "Bar.hpp"
using namespace std;
class Foo {
shared_ptr<Bar> bar;
//other members omitted
};
#endif /* FOO_HPP_ */
I get a compile time error: template 1 is invalid (for the bar member).
Bar.hpp looks approximately like:
#ifndef BAR_HPP_
#define BAR_HPP_
#include "Foo.hpp"
using namespace std;
class Bar {
//private and protected member omitted
public:
//other public members omitted
virtual int collide(bool p, Foo& f) = 0;
};
#endif /* BAR_HPP_ */
If I now replace the #include "Bar.hpp"
in "Foo.hpp" with class Bar;
, CDT will underline it with an error: forward declaration of 'class Bar'
How can I resolve this issue?