mardi 8 décembre 2020

Why do templated class members variables require the static keyword?

What is the rationale that this does not compile

class Math{
   template<typename T>
   std::map<int, T> m; // error: member 'm' declared as a template
}

while putting the static variable compiles as such?

class Math{
   template<typename T>
   static std::map<int, T> m;
}

Thank You !

Aucun commentaire:

Enregistrer un commentaire