[quote=引用 12 楼 taodm 的回复:] 要用全局变量或者static变量。
[quote=引用 7 楼 wtwhs1985的回复:][quote=引用 6 楼 真相重于对错 的回复:] template<int i>可以这么写,但是实例化时候必须是能在编译期确定的量 比如 template<int i> void test(){} void main(){ test<1>(); }
template<int* i> void test(){ std::cout << *i << '\n';} int a; int main(int argc,char* argv[]) { test<&a>(); return 0; }
要用全局变量或者static变量。
[quote=引用 6 楼 真相重于对错 的回复:] template<int i>可以这么写,但是实例化时候必须是能在编译期确定的量 比如 template<int i> void test(){} void main(){ test<1>(); }
template<int i>可以这么写,但是实例化时候必须是能在编译期确定的量 比如 template<int i> void test(){} void main(){ test<1>(); }
64,636
社区成员
250,540
社区内容
加载中
试试用AI创作助手写篇文章吧