Dynamic Memory Allocation C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Dynamic Memory Allocation C++

Hello! I have two files in which one of them is included in the other. I have written this: Board[0][1]= new ClassA (true,0,1,*this); yet I get a compiler error saying :"expected type-specifier before 'ClassA'", even though I have declared it in that particular scope.

28th Jul 2019, 6:05 PM
MargK645
4 Answers
0
Any chance of getting more than just the one line of code?
28th Jul 2019, 7:02 PM
James
James - avatar
0
James https://code.sololearn.com/cq07Hj6xEqG8/?ref=app Please check out only the parts where declaration of class Soldier occurs. Thank you!
28th Jul 2019, 7:14 PM
MargK645
0
So you are dealing with a few files. The compiler can't find the type. 1. Make aure you are accessing it in the right scope. 2.Make sure you properly #inluded all your files. 3. Make sure your inclusion guards match. I can't actually sit down and read through everything at the moment. I will have time a bit later. Those are usually a pretty good place to start.
28th Jul 2019, 7:28 PM
James
James - avatar
0
James thank you for taking time to check on my code. The thing that was weird about it is that everything turned out well for the other figures and the soldier figure was the one with the problem concerning the declaration scope even though I did the exact same things that I did for the other figures.
28th Jul 2019, 7:30 PM
MargK645