I am using structure that involves some POD and UnicodeString, e.g.
struct TMyStruct
{
int value1;
bool value2;
UnicodeString mystring;
}
Now to make this into an array I use std::vector
std::vector<TMyStruct> myarray;
myarray.push_back(TMyStruct());
... etc.
I need to know do I need something more than that to use it like this – like a copy constructor for UnicodeString part, deep copy, destructor for the struct and things like that or is the above sufficient to use UnicodeString as an array of structs?
Will UnicodeString(s) automatically be destroyed when vector goes out of scope – in other words will it decrease reference counter for all of them?
Also, is there a more VCL-like way to use structures like this in an array. Is there a better way to use non-POD data in a structure as an array of structs?
Examples and other methods appreciated.
No, you do not need to define your own copy constructor or destructor.
UnicodeStringhas its own copy constructor and destructor. The default compiler-generated copy constructor and destructor forTMyStructwill invokeUnicodeString‘s constructor and destructor automatically in your example.