模板中的静态类对象C++
问题描述:
template<int max_number> class Test {
private:
// static object definition
static Test Global;
public:
// constructor
Test(int x){
int y;
y = x;
}
//static object definition inside template
Test::Global(5);
};
Test :: Global(5);我怎样才能在模板中声明类对象实例?什么签名应该是?模板中的静态类对象C++
答
template < int max >
struct Test { static Test global; };
template < int max >
Test<max>::global(5);
您没有显示错误信息 – DMaster