简体   繁体   English

错误:在'&'标记之前预期')'

[英]Error: Expected ‘)’ before ‘&’ token

In the following code the compiler is showing error in second line while if I am not using a template class and explicitly defining V then it works fine. 在下面的代码中,编译器在第二行显示错误,而如果我没有使用模板类并明确定义V,那么它可以正常工作。

template <class T,template <class T> class V>
void struct inp<T, V >::input(ifstream& in, V<T> lst)

You can't have both void and struct in your template declaration. 模板声明中不能同时包含void struct Are you talking about a templated function or a templated class? 你在谈论模板化的函数还是模板化的类? And you probable want a const ref to that ifstream and at least a non-const refernce to your templated class template parmater. 你可能想要一个const引用ifstream和至少一个非const引用你的模板化类模板parmater。 You want either a class: 你想要一个班级:

template <class T,template <class T> class V>
struct inp<T, V >::input(const ifstream& in, V<T>& lst)

or a function: 或功能:

template <class T,template <class T> class V>
void inp<T, V >::input(const ifstream& in, V<T>& lst)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM