I'm writing a library which is totally base on templates, so I don't have any cpp files. Now I want to declare an global variable, then I realize I have nowhere to go.
If I simply declared it in header, I will got a "multiple definition" error, if I use extern
, I have to create a cpp file to really declare it.
So is there any way I can declare a global variable in header?
P.S. since a static member in a template class can (only) be declared in header, how it works?