Trying to understand which is more efficient.
- Initialize unordered_set member variable as a static member variable
- Initialize unordered_set member variable in the constructor
Is one better than the other in terms of less memory usage?
class Example
{
private:
enum Names
{
JOHN,
MIKE,
CHARLIE,
TOM
};
static unordered_set<Names> checkNames_v1;
unordered_set<Names> checkNames_v2;
public:
// Constructor
Example()
{
checkNames_v2.insert(JOHN);
checkNames_v2.insert(MIKE);
};
};
unordered_set<Names>Example::checkNames_v1
{
JOHN,
MIKE
};