How are allocated objects inside a struct dynamically created ?

If I have :
1
2
3
struct my_struc {
 vector<float> my_vector_of_floats;
};

and I create an instance :

my_struc a_instance_of_mystruct = new my_struc;

Where is allocated the vector?
Have I to write :

vector<float> * my_vector_of_floats;

inside the struct, to let dinamyc memory use ?

Thanks
Last edited on
No, it will work fine without a pointer. The vector is allocated in the space for the structure. It is basically just a bunch of variables in a row in memory.
A vector itself has pointers to a bunch of memory, the vector itself does not contain the memory. This is a common misconception.
Topic archived. No new replies allowed.