dataComb=getData.toString()+data.toString();// i combined the values of string of x,y cordinates and sunType etc
dataStore[counter]=dataComb;// i stored them here
as you can see i am trying to copy the values of dataStore[] into my function computeCivicIndex()
i tried doing it in this way but it returns me with a error which says
locationData.cpp: In member function ‘float locationData::computeCivicIndex(std::string*)’:
locationData.cpp:101: error: name lookup of ‘i’ changed for ISO ‘for’ scoping
locationData.cpp:101: note: (if you use ‘-fpermissive’ G++ will allow the code to compile)
may i know the correct way of doing this?
i am supposed to take in the values from the array and used it in the computation process in computeCivicIndex() method
That error is due to the the ; on line 4. Although assigning thing to itself is no good anyway. To make a copy of array arr of type T and length len do
1 2
T* copy = new T[len];
for(int i = 0; i < len; i++) copy[i] = arr[i];
Don't forget to delete copy later.
Although if you use std::vector instead of an array, the copy will be made automatically when passed by value or on plain assignment. If you ever want to avoid copy, pass by reference.