What is the correct way to initialize static data members in C++ (98, 11 and 14)
问题 What is the right way to initialize static data members in C++? I'm also interested in how it has changed from C++98, to C++11 to C++14. Here is an example: // bufferedOutput.h class BufferedOutput { // Static member declaration. static long bytecount; }; // bufferedOutput.cpp long BufferedOutput::bytecount = 50; Are there other ways to initialize static data members? 回答1: The rules have always been as follows: A const static data member (SDM) of integral or enumeration type can be