[英]Expected type-specifier before ';' token
I get the error "Expected type-specifier before ';' 我收到错误消息“';'之前的预期类型说明符” token" in a line of code marked below.
令牌”在下面标记的代码行中。 Is it asking to specify the type of (*this)?
是否要求指定(* this)的类型? Why wouldn't the compiler know the type of (*this)?
为什么编译器不知道(* this)的类型?
struct P{
};
struct R : public P{
virtual P* copy(){
return new(R(*this)); //error here
}
};
You need to say: return new R(*this);
您需要说:
return new R(*this);
That's the form of the non-placement new
-expression. 这就是非放置
new
表达式的形式。 No extra parentheses. 没有多余的括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.