I am making a simple C++ game based loosely on Starcraft. This is a way to practice pointers.
The program works fine so now im adding the little technical stuff in this case, the Cloaking ability ghost
In the ghost .If i take out the loop, it doesnt give me an error.
any help is much appreciated
here is my ghost.cpp
1 Answer 1
The proper way to do this is to remove the while loop and check if cloak is true in your methods. Here is a implementation that will not give you the errors(assuming cloak is a member variable, which it should be in this case):
Note: Also note the comment that you can not have a while loop outside of a function in C++ like the commentator said.
Not the answer you’re looking for? Browse other questions tagged c++ or ask your own question.
Related
Hot Network Questions
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459
что делать если ошибка expected unqualified-id before ‘if’
void setup() <
pinMode(6, INPUT);
>
int K = digitalRead(6);
// (Если я правильно понял то здесь задаётся количество шагов на оборот, у меня 200)
#define STEPS 100
Keep Getting This Error On Line 12

1 Answer 1
Your code is missing a int main(void) function in which all of your code should be inside. By definition, a C++ program is required to have a int main(void) function. You need to put all your code inside the int main(void) function.
Also, your cin and cout statements are missing the namespace tag std:: . Therefore, you need to add the std:: at every instance you use cin or cout See the code below: