jeudi 3 novembre 2016

Initialization of static const member map<> in class definition

I'm gonna to have a const std::map in my class, and I want it be static to reuse the data structure. Unfortunately, it won't compile due to this:

However, we can provide in-class initializers for static members that have const integral type and must do so for static members that are constexprs of literal type (Primer 5th).

My code is looks like :

clase worker {
//.....
private :
//.....
static map<string, string> const map_;
}

So, is there a OOP technique to reuse this data structure, assuming that we have tens of worker and map_ is big?

Aucun commentaire:

Enregistrer un commentaire