[英]Expected type-specifier before ';' token
我收到錯誤消息“';'之前的預期類型說明符” 令牌”在下面標記的代碼行中。 是否要求指定(* this)的類型? 為什么編譯器不知道(* this)的類型?
struct P{
};
struct R : public P{
virtual P* copy(){
return new(R(*this)); //error here
}
};
您需要說: return new R(*this);
這就是非放置new
表達式的形式。 沒有多余的括號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.