As a few of you already know, I have started teaching myself c++ with a book called "Beginning C++ Through Game Programming." I've been using MS Visual C++ Express Edition, but my PC is really old and really slow, and it would be much easier to code on my Mac. So I installed Xcode, but when I tried entering a program from the book, it generated an error, and this exact same program worked fine on Visual C++. The error message was for this line
difficulty myDifficulty = EASY;
and the error message was
Unused variable 'myDifficulty'
It seems to me that 'myDifficulty' should have been declared, but since it worked on my PC, I'm assuming there's probably a concept here that I'm not understanding, since my understanding of c++ is extremely limited.
Anyway, I'm just wondering if I should go back to entering these programs on my old PC, or if there's a way to make them work on my new(ish) Mac. I can't afford a new computer right now, so those are my only options.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
int main()
{
const int ALIEN_POINTS = 150;
int aliensKilled = 10;
int score = aliensKilled * ALIEN_POINTS;
cout << "score: " << score << endl;
enum difficulty {NOVICE, EASY, NORMAL, HARD, UNBEATABLE};
difficulty myDifficulty = EASY;
enum shipCost {FIGHTER_COST = 25, BOMBER_COST, CRUISER_COST = 50};
shipCost myShipCost = BOMBER_COST;
cout << "\nTo upgrade my ship to a Cruiser will cost "
<< (CRUISER_COST - myShipCost) << " Resource Points.\n";
return 0;
}
|