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?

29th Jul 2019, 6:38 PM
MargK645
14 Respuestas
+ 2
Post code.....
29th Jul 2019, 6:44 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
29th Jul 2019, 9:55 PM
MargK645
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
30th Jul 2019, 4:52 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Ketan Lalcheta here is the class Piece thank you for helping https://code.sololearn.com/c9PwApGhQhfM/?ref=app
30th Jul 2019, 7:17 AM
MargK645
0
Ketan Lalcheta could you find anything? Thank you!
30th Jul 2019, 9:16 AM
MargK645
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
31st Jul 2019, 2:50 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
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
31st Jul 2019, 6:23 AM
MargK645
0
Ketan Lalcheta any chance you fixed it?😁
31st Jul 2019, 2:52 PM
MargK645
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?
31st Jul 2019, 3:00 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Ketan Lalcheta yes it does end with a semicolon
31st Jul 2019, 3:09 PM
MargK645
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.
1st Aug 2019, 4:38 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
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++
1st Aug 2019, 5:37 AM
MargK645
- 1
let me also try this to figure out on laptop if it is still not solved
30th Jul 2019, 3:01 AM
Ketan Lalcheta
Ketan Lalcheta - avatar