Consider the following polymorphisme case:
class Shape {
public:
Shape();
virtual void draw() = 0;
virtual ~Shape();
}
class Triangle : public Shape {
public:
Triangle();
void draw();
~Triangle();
}
class Square : public Shape {
public:
Square();
void draw();
~Square();
}
class Circle : public Shape {
public:
Circle();
void draw();
~Circle();
}
class Container {
public:
void addShape(string type); //Create and add instance of selected type to render_list
void render(); //iterate through render_list and draw() each object
private:
vector<Shape*> render_list;
}
If render() method is called by a scheduler at fast rate: is this a good way of implementing an heterogenous collection ?
Will the vtable use be a problem for performance ?
Is there any alternative ?
Best,
Louis