|
|
#2
rjsp2021-08-03 23:12
|
程序代码:#include <iostream>
using namespace std;
template<class T>
class sring{
public:
T data;
constexpr sring(T d):data(d){}
};
int main(){
sring a=1;
cout<<a.data;
}
结果是这样,gcc,windows上
程序代码:c:\c++>g++ shiyan.cpp
shiyan.cpp: In function 'int main()':
shiyan.cpp:18:11: error: missing template arguments before 'a'
sring a=1;
^
shiyan.cpp:19:11: error: 'a' was not declared in this scope
cout<<a.data;