-
Notifications
You must be signed in to change notification settings - Fork 628
/
Copy path1config3.cpp
43 lines (33 loc) · 984 Bytes
/
1config3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//file:1config3.cpp
//测试在class template中拥有static data members
//test __STL_STATIC_TEMPLATE_MEMBER_BUG,define in <slt_config.h>
//
//编译器:clang-800.0.42.1
#include <iostream>
using namespace std;
template <typename T>
class testclass
{
public:
static int _data;
};
template<> int testclass<int>::_data = 1;
template<> int testclass<char>::_data = 2;
int main()
{
cout<<testclass<int>::_data<<endl; //1
cout<<testclass<char>::_data<<endl; //2
testclass<int> obji1, obji2;
testclass<char> objc1, objc2;
cout<<obji1._data<<endl; //1
cout<<obji2._data<<endl; //1
cout<<objc1._data<<endl; //2
cout<<objc2._data<<endl; //2
obji1._data = 3;
objc2._data = 4;
cout<<obji1._data<<endl; //3
cout<<obji2._data<<endl; //3
cout<<objc1._data<<endl; //4
cout<<objc2._data<<endl; //4
return 1;
}