Sorry for the confusing title. Hopefully an example will clear things up. I have a base class called Renderable like this:
class Renderable {
public:
virtual void render() = 0 ;
};
I plan to iterate through an std::vector of references of derived classes of Renderables. Like this:
std::vector<Renderable&> allRenderables = //passed in somewhere;
for (Renderable& renderable : allRenderables) {
renderable.render();
}
I compiled and this is what I get:
Error C2528: <template-parameter>: pointer to reference is illegal
I tried deleting & but it tells me that Renderable is abstract. Also, I think this is a poor way to implement things.
Could someone please tell me what I got wrong? Or is this the right way to implement this at all?
I thank you in advance!