1.there are no arguments to '*****' that depend on a template parameter, so a declaration of '******' must be available
这个问题产生可以检查是否应用了名字空间。
我曾经写的代码出现了这个错误
template <typename T>
void queue_psn<T>::enqueue(T t) {
try {
if(full_q()) {
throw overflow_error("overflow"); //错误语句
//throw std::overflow_error("overflow") 正确语句
}
q[tail] = t;
if(tail == len) {
tail = 1;
}
else {
tail += 1;
}
len += 1;
}catch (overflow_error err) { //错误语句 正确语句应该是:std::overflow_error err
std::cout << err.what() << std::endl;
}
error: there are no arguments to 'overflow_error' that depend on a template parameter, so a declaration of 'overflow_error' must be available [-fpermissive]
throw overflow_error("overflow");
2.error: expected ')' before '<' token
expected '}' at end of input
可以看看是不是缺少了命名空间
template <typename data>
class link {
public:
typedef unsigned size_type;
link(): len(0) {};
link(initializer_list<data> in) { //这里报错了,应该是std::initializer_list<data> in
for(auto i = in.begin(); i != in.end(); ++i) {
l[len] = *i;
++len;
}
}