C
Cristiano
I have a structure like this (the actual structure is much bigger):
struct Generic {
char ID[6];
std::vector <obj1_info> info1;
std::vector <obj2_info> info2;
std::vector <obj3_info> info3;
std::vector <obj4_info> info4;
};
I use it to store 4 types of objects.
Each object needs its own std::vector to store informations related to
that object.
To avoid wasting of space I though to use a void * instead:
struct Generic {
char ID[6];
void *ptr;
};
Not a good idea, I know.
First question: does anybody have a good idea?
I allocate the right std::vector using:
ptr= new std::vector<obj1_info>;
obj1_info x; x.var= 0;
((std::vector<obj1_info>*)ptr)->push_back(x);
but when I try to read x (using some horrible casting) I get errors
(violation access, wrong result).
How should I cast the ptr pointer?
Thanks
Cristiano
struct Generic {
char ID[6];
std::vector <obj1_info> info1;
std::vector <obj2_info> info2;
std::vector <obj3_info> info3;
std::vector <obj4_info> info4;
};
I use it to store 4 types of objects.
Each object needs its own std::vector to store informations related to
that object.
To avoid wasting of space I though to use a void * instead:
struct Generic {
char ID[6];
void *ptr;
};
Not a good idea, I know.
First question: does anybody have a good idea?
I allocate the right std::vector using:
ptr= new std::vector<obj1_info>;
obj1_info x; x.var= 0;
((std::vector<obj1_info>*)ptr)->push_back(x);
but when I try to read x (using some horrible casting) I get errors
(violation access, wrong result).
How should I cast the ptr pointer?
Thanks
Cristiano