I have a struct, for example this one:
struct TMyStruct {
int v1;
std::string abc;
TMyStruct() { Init(); }
void Init() {
v1 = 1;
abc = "text";
}
}
std::vector<TMyStruct> ms;
ms.push_back(TMyStruct());
// ... etc.
It works nicely.
My concern is - does the above structure uses more memory because of the additional functions for initialization in this case (but could be anything else) when allocated in a vector? Or should I use the struct without any additional functions for example:
struct TMyStruct {
int v1;
std::string abc;
}
std::vector<TMyStruct> ms;
ms.push_back(TMyStruct());
ms.back().v1 = 1;
ms.back().abc = "text";
// etc...