*** C++静态成员变量的初始化

#include <iostream>
#include <string.h>
using namespace std;
class demo
{
public:
    static int i;                 // 这里不可以初始化非const static变量!
    static const int j = 1; // 1st place to initiate for const static variable
};
int demo::i = 0;       // only place to initiate for non-const static variable
//const int demo::j = 1; // 2nd place to initiate for const static variable
int main()
{
    return 0;
}

 

posted @ 2018-12-23 18:48  super行者  阅读(463)  评论(0编辑  收藏  举报