I'm getting an error on the following code snippet;
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;
struct tuple {
int x;
int y;
};
int main() {
//srand(time(NULL));
vector<tuple> locations;
int dimentions = 20;
double filledness = 0.65;
while (locations.size() < dimentions * dimentions * filledness) {
tuple point;
point.x = rand() % dimentions;
point.y = rand() % dimentions;
locations.push_back(point);
}
int count = locations.size();
tuple start, end;
start = locations[rand() % count];
end = locations[rand() % count];
cout << count << endl;
for (int i = 0; i < locations.size(); i++) {
cout << locations[i].x << " " << locations[i].y << endl;
}
cout << start.x << start.y << endl;
cout << end.x << end.y;
return 0;
}
The vector initialization is in my main and the struct outline just above. I obviously don't understand something about vectors. I've tried making the struct a class as well as replacing vector of tuples with a vector of tuple*.
Can someone please explain why a vector can't be used in this way,
I would prefer if you didn't tell me how to fix the error directly.
error: template argument 1 is invalid
vector<tuple> locations;