Я получаю сообщение об ошибке в следующем фрагменте кода:
#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;
}
Инициализация вектора у меня в основном, а структура приведена чуть выше.Я явно не понимаю что-то о векторах.Я попытался сделать структуру классом, а также заменить вектор кортежей на вектор кортежей *.
Может кто-нибудь объяснить, почему вектор нельзя использовать таким образом,
Я бы предпочел, если бы вы не сказали мне, как исправить ошибку напрямую.
error: template argument 1 is invalid
vector<tuple> locations;