templates vs switch
<p>I'm trying to find my ways in the C++ land and am increasingly confused by now. The toy application is a very basic OpenGL engine.
So here's the (I guess simple) problem:
I'd like to handle meshes of different vertex data, so I'd have e.g.</p>

<pre><code>struct Vertex
{
    Vector3f position;
}

struct VertexN : public Vertex
{
    Vector3f normal;
}
</code></pre>

<p>Now I need a Mesh class, that holds the data and draws it.
I've tried something like this:</p>

<pre><code>template&lt;class T&gt;
class Mesh
{
    public:
        Mesh();
        ~Mesh();

        void load(const T * vertices, int num);
        void draw();

    protected:
        T * vertices_;
</code></pre>

<p>};</p>

<p>The different vertices have to be loaded and drawn differently and this can be done with template specialization. </p>

<p>My problem is that I like to have another class that holds instances of Mesh objects, but templated class members are obviously not allowed.</p>

<p>The other solution I can think of is to hold pointers to the base struct Vertex in Mesh, pass an identifier for the Vertex type used and then use switch statements in load() and draw() to allow for the different implementations.</p>

<p>What is the best way to accomplish this?</p>

<p>Any help is greatly appreciated.</p>
