64,639
社区成员
发帖
与我相关
我的任务
分享
class test
{
public:
static const int i=5;
};
const int test::i;
#include "stdafx.h"
class test
{
public:
static const int i;
};
const test::i = 5;
int main(int argc, char* argv[])
{
return 0;
}
g++:
1 #include <iostream>
2 using namespace std;
3
4 class A
5 {
6 public:
7 static const int sc_data = 5;
8 };
9 int main()
10 {
11 A a;
12 cout<<a.sc_data<<endl;
13 return 0;
14 }
$ g++ tes.cpp
$ ls
a.out* test.cpp
$ ./a.out
5