I have a vector that stores data from a custom structure.
Ok, depending of some value I need to store addicional data of another structure.
In example :
structureA name, age, .... have_B_data.
structureB address, phone, etc ( a lot of data).
Ok I'd can have two sincronized vectors , vecA fos structA and vecB. for strucB.
I 'd want to do:
vecA.push_back(structureA)
if not have_B_data vecB.push_back(empty data) ' zero bytes .
if have_B_data vecB.push_back(structureB)
I have the idea of to avoid the spent of memory if it isn`t needed.
Any idea to do this ?
Thanks
There are a number of ways to do this but it really depends on what the data is and how you want to use it. One way would be to store the index of the B record in A. A negative index could indicate that there is no associated B record.
I understand.
I know that I can have two vectors the main for A and another for B. Inside A I can have an index to vectorB.
But I'd not want to do this...
Thanks again.