|
-
March 8th, 2011, 07:51 PM
#1
class Timer error message :O
I keep getting this error whenever I compile my program. I am using XCode and am not sure of what to do or how to fix this error.
Code:
#define TIMER_H_DEF
#include <iostream>
#include <string>
#include <sys/time.h>
int main ()
class Timer // <----- Error: Expected initializer before 'class'
{
public:
timer();
~Timer();
using std::cout;
using std::cin;
using std::string;
int enter, gold, number, america, newgold;
int twogold, city, threegold, passcode;
// Beginning of game.
cout << "Welcome to the coin game. "
<< "The objective is to get 1000 coins by the end.\n"
<< "\nNow please create a random 8 number passcode "
<< "using ONLY numbers.\n";
cin >> enter;
while (enter <= 10000000 || enter >= 99999999 ) {
cout << "\nYour passcode is less than 8 digits "
<< "(do not use 0 as the first digit).\n";
cout << "Please try again.\n";
cin >> enter;
}
cout << "\nFirst, solve 432 * 23, "
<< "in order to get your first 50 coins "
<< "(no calculators!).\n";
timer.start();
cin >> number;
timer.stop();
cout << "You took "
<< timer.getElapsedTimeInMilliSec
<< " ms "
<< "to solve the equation.";
This is not the entire program so don't worry if you don't see a return 0 or anything.
-
March 9th, 2011, 09:00 AM
#2
Re: class Timer error message :O
Your class definition cannot be inside a method. Have it outside the main() function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|