Expected type-specifier before ';' token

c++, class, inheritance

Solution

You need to say: `return new R(*this);` That's the form of the non-placement `new`-expression. No extra parentheses.

Problem

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)? Why wouldn't the compiler know the type of (*this)? ``` struct P{ }; struct R : public P{ virtual P* copy(){ return new(R(*this)); //error here } }; ```

Original source