The following struct should hold a shared_ptr to an abstract base class (Shape). However, when I try to write this, I get error C2065: 'Shape' : undeclared identifier
.
So I know that I can't create instances of Shape, only instances of the derived Spheres, Boxes, etc. But why can't I use a shared_ptr to an abstract base class?
#include <memory> // std::shared_ptr
#include "shape.hpp"
struct Hit {
// …
std::shared_ptr<Shape> m_shape; // Shape that was hit
};
It should be noted that indeed the Shape class is using the Hit struct and vice versa.