error in for loop..

I am getting the following error


1
2
3
4
5
timeseries.cpp: In constructor ‘NEAT::Timeseries::Timeseries()’:
timeseries.cpp:88:72: error: expected primary-expression before ‘static_trainingdata_iter’
timeseries.cpp:88:72: error: expected ‘;’ before ‘static_trainingdata_iter’
timeseries.cpp:88:145: error: ‘static_trainingdata_iter’ was not declared in this scope
make: *** [timeseries.o] Error 1


where line 88 is this (I simplified it to something pretty useless but it illustrates that the error does in fact occur here:

for (t = buffer_period, std::vector<std::vector<float>*>::iterator static_trainingdata_iter = static_trainingdata->begin() + buffer_period; static_trainingdata_iter != static_trainingdata->end(); static_trainingdata_iter++, t++);

if I take out the statements with the t and replace it with the following the error goes away and it compiles fine:

1
2
t = buffer_period;
for (std::vector<std::vector<float>*>::iterator static_trainingdata_iter = static_trainingdata->begin() + buffer_period; static_trainingdata_iter != static_trainingdata->end(); static_trainingdata_iter++) t++;


but aren't these 2 pieces of code identical?
Last edited on
Well, you can't declare things after a comma. Note that here ',' is the comma operator rather than special syntax. You can't do a = 5, int b = 7 the same way you can't do (a = 5) + (int b = 7).
makes sense. thanks :)
Topic archived. No new replies allowed.