Cpp error | SoloLearn: Learn to code for FREE!

0

Cpp error

Hello. I am creating a cpp console mode chess game and I have written this line of code: Board[1][0]=new Soldier(true,0,1,*this); (soldier is my class) when I run it I get this: expected type-specifier before soldier. However, I've written this line for the other figures as well, however, this error does not appear for them. What can I do?

7/29/2019 6:38:12 PM

MargK645

14 Answers

New Answer

+2

Post code.....

0

https://code.sololearn.com/cq07Hj6xEqG8/?ref=app

0

Paolo De Nictolis

0

let me also try this to figure out on laptop if it is still not solved

0

Your code is incomplete. It has no definition to class Piece. Could you please post complete code to look into it? Or at least put replica of your code which get builds except your error one

0

Ketan Lalcheta here is the class Piece thank you for helping https://code.sololearn.com/c9PwApGhQhfM/?ref=app

0

Ketan Lalcheta could you find anything? Thank you!

0

it's constructor is public only and with appropriate number of argument.... seems it's not problem of code... just class is not recognised by compiler.... do one thing....#pragma once should be replaced by #ifndef #define #endif to try with as many compiler ignores pramga once... but this reason should give error about multiple definition rather than missing type declaration... let me check this one more time in detail and try to replicate your scenario

0

Ketan Lalcheta I will try that thank you! If you have anything new please let me know! I will also try to substitute #pragma once

0

Ketan Lalcheta any chance you fixed it?😁

0

could not get a chance but surely will look into it once.... as you mentioned earlier that other classes are working fine except soldier class, can you ensure below once ? class soldier { }; does class ends with semicolon?

0

Ketan Lalcheta yes it does end with a semicolon

0

I just created six different files (three each of .h and .cpp) from your codes. removed code to initialize object of class other than soldier class and it got build on VS 2015. Seems you are missing something which can only be identified by having proper access to your code fully. To check one more point, hope you are not playing with namespaces. All class codes are into same scope.

0

Ketan Lalcheta oh thank you, well the truth is that I so not pay attention to namespaces. I am building this program on DEV C++