预期的'int'之前的unqualified-id [英] expected unqualified-id before ‘int’
本文介绍了预期的'int'之前的unqualified-id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class A {
public:
virtual ~A() {};
virtual int emit(int t, void* a)=0;
};
template <class dest_type="">
class B : public A {
public:
typedef int (dest_type::*classpfn)(int, void*);
B(dest_type* pclass, classpfn pfn) : p(pclass), fn(pfn) {};
virtual int emit(int t, void* a) { return (p->*fn)(t, a); }
private:
dest_type *p;
classpfn fn;
};
输出:
=======
abc.h:222:错误:在'int'之前的预期unqualified-id
abc.h:222:错误:预期在'int'之前的')'
Output:
=======
abc.h:222: error: expected unqualified-id before ‘int’
abc.h:222: error: expected ‘)’ before ‘int’
推荐答案
这部分template<class dest_type="">
,对我来说很奇怪,您是否要设置默认类型dest_type
为空字符串吗?
尝试删除该内容,以使您离开template<class dest_type>
.
希望这会有所帮助,
弗雷德里克(Fredrik)
This parttemplate<class dest_type="">
, looks weird to me, are you trying to set the default typedest_type
to an empty string?
Try removing that so that you''re left withtemplate<class dest_type>
.
Hope this helps,
Fredrik
这篇关于预期的'int'之前的unqualified-id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文