I need to know how I can declare a vector with an identifier I know that doesn't make much sense so heres some pseudo code to explain
vertex_type vert(identifier) //this declares that vert is of the vertex type.
Please understand this and help??
I need to know how I can declare a vector with an identifier I know that doesn't make much sense so heres some pseudo code to explain
vertex_type vert(identifier) //this declares that vert is of the vertex type.
Please understand this and help??
Please elaborate. If you have a type vertex_type, declaring
vertex_type vert
would make vert of type vertex_type. From your pseudocode all I get is maybe you want a constructor or something...?
I'm confused though.
Sorry about the confusion, I read it later but didn't make sense
I want to be able to declare a vector with a name that is different each time the user clicks the left mouse button.
For example
1 click= vertex_type v1
2nd click= vertex_type v2
How would I do this with out declaring 50 million vertex_types??
Hope you understand this
Array.
vertex_type* v;
v = (vertex_type)malloc(num * sizeof(v));
Then when the user clicks:
++num;
v = (vertex_type)realloc(v, num * sizeof(v));
Words of notice:
That code is not tested. Also, malloc and realloc are nasty ugly dirty old C functions (well, they're not that bad, but most people would prefer new). But I don't know how to reallocate memory allocated with new without losing data other than creating a temporary array, filling it with the original array data, deleting the orig. array, recreating the orrig. array with the new size, filling up to orig. size the new array with the data from the temporary array. (-_- phew). There's probably a better way, but unfortunately I don't know it
You could use an STL container; like a vector.
Code:#include <vector> // ... std::vector<vertex_type> vertexlist; OnClick(...) { vertexlist.push_back(vertex_type(...)); }