Inheritance, expected type-specifier before error

10,142

Solution 1

In the file that has the statement

Piece * p = new Pawn(c);

you seem to forget to include corresponding header files.

Solution 2

I had encountered a similar problem. It turned out I copied and pasted from a previous class and forgot to update my #ifndef statement at the top of my new header file. The compiler was ignoring my new header file because I told it to. D'oh!

Share:
10,142
MrBrightside
Author by

MrBrightside

SOreadytohelp

Updated on June 04, 2022

Comments

  • MrBrightside
    MrBrightside almost 2 years

    Well I'm trying to figure out inheritance in c++, and I'm getting a compile time error error: expected type- specifier before 'Pawn'. I get this on the following line

    Piece * p = new Pawn(c);
    

    I removed this code because I got worried about people using my code for the assignment I was doing at the time. I apologize if this caused any inconvenience, if you have any specific questions contact me.

    I'm aware there may be some other errors but This is the one I'm at a loss with. Thanks in advance for your help!