| ojima (9) | ||||||
|
Hello everybody, I'm currently working on a simple ASCII-game in the console, and I've stumbled upon a problem while making a class for a "monster". To explain my problem, let me first explain my projection on the game. I'm using for the view 4 variables, the x and y of the view, and the width and height (called xView, yView, wView and hView). Each variable is declared at the beginning of the code, which looks like this: MAIN.CPP
The code for in the file "monsterclasses.cpp" is:
But when I try to compile the code, the compiler (Code::Blocks) gives me the following error:
and for all the 5 other variables (yView, wView, hView, wRoom, hRoom) as well... Now I wonder, is this an errorr in the main code, or should I just place the code from "monsterclasses.cpp" in the main code? - Ojima | ||||||
|
Last edited on
|
||||||
| Vins3Xtreme (85) | |
you give this error because you declare the 'cView' and the others variable 'after' the #include monsterclasses.cpp , those variables not exist for CMonster. However, i just suggest you to split the 'definition' and the 'implementation' of the class 'CMonster' into to file '.h' for definition and '.cpp' for implementation. Then you include in the main.cpp only the .h file of CMonster.
| |
|
|
|