Compiler error ISO C++ forbids initialization

The compiler is giving me an error: iso c++ forbids initialization of member 'raceFinish'. Is there anything I'm not doing here?

1
2
3
4
5
6
7
8
9

#include <iostream>
#include <time.h>
#include <cstdlib>

using namespace std;


Last edited on
That kind of initialization wasn't part of C++ until C++11. Look into enabling that, or initialize in the constructors
line 48 is the problem. you can only initialize a data member from a function in the class.

You will prefarably do this in race constructor just as you did for length .

1
2
3
 
int length //line 45 
length = 25 //line 54 

Do same for raceFinish
Topic archived. No new replies allowed.