Jump to content
  • Advertisement
Sign in to follow this  
Hunter_Ex

template class problem

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i dont know if this is solveable :S but anyway can i apply this code to a class or struct etc.. before.. struct STRUCT { // psuedo unsigned/virtal Vertex; }
// psuedo
VERTEX * class/struct->Vertex new VERTEX[size];


after.. struct STRUCT { // psuedo VERTEX Vertex[size]; } so it maybe deletes the old Vertex in the class and adds it with the new is there any other way to makesomething like this is a linked list useable at this? greet hunter_ex

Share this post


Link to post
Share on other sites
Advertisement
okay im getting a new idea

how about making a linked list with different types and values in each node
how can that be done

like everytime i add a new node i also specify witch data types there will be in that node

i cant use a structure couse then i need to use the same types in each node

example:


Head --> Node1 --> Tail

INT data VOID *data; DOUBLE data;
INT head_data; VERTEX vertex[10]; FLOAT my_float;
INT more_data // only at this node

Share this post


Link to post
Share on other sites
I actually have no idea what you are trying to do. But, if you are going to be storing objects, and the objects have a relationship to each other, you could always try having an abstract class, and having other derive from it, so you could have a single list of the base pointer type.


class A{

};

class B : public A
{

};

class C : public A
{

};



// blah blah
list<A*> obj_list; // create a list of A* objects (will be able to hold a pointer to ANY object that is derived from class A)

obj_list.push_back( new B ); // add an object of type B to the list
obj_list.push_back( new C ); // add an object of type C to the list




Else, you can look into boost::variant, which I'm sure many people can help you with (I haven't used it personally).

If this isn't what you are looking for, is this an existing system that you want to re-write? If so, post the code that you currently have, and someone can probably help you.

Share this post


Link to post
Share on other sites
ok i fixed my problem but
how can i set a new size to an array?

like


class Vertex
{
VERTEX vertex[1];

inline Vertex(int size) {
// resise vertex array to "size"
~Vertex();
}



how can i do that?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!