3

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!

3
  • 2
    looks like you missed #include "Pawn.h" in your Pawn.cpp Commented Nov 28, 2011 at 1:25
  • Please show the code that surrounds the erroneous line. Also, consider simplifying your example code (see sccee.org). Commented Nov 28, 2011 at 1:25
  • Please also give your main program Commented Nov 28, 2011 at 1:28

2 Answers 2

8

In the file that has the statement

Piece * p = new Pawn(c);

you seem to forget to include corresponding header files.

Sign up to request clarification or add additional context in comments.

1 Comment

ok, I didn't know what to put up, people always tell me to post more, so I posted more, I'm sorry, Yes I'm amazed you could tell that. thank you so much
5

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.