我在C++中有点新,在尝试编译这段代码时,我得到了一个我不知道如何修复的错误:
int main()
{
typedef pair<int,int> nodo;
int x;
cin >> x;
int *g;
g = new int[x];
vector <nodo> g;
g[1].push_back(nodo(2,5));
g[1].push_back(nodo(3,10));
g[3].push_back(nodo(2,12));
g[2].push_back(nodo(4,1));
g[4].push_back(nodo(3,2));
for (int i = 1; i <=4; ++i){
// cout << i << " -> ";
for (int j = 0; j<g[i].size(); ++j){
// cout << g[i][j].first << " c: " << g[i][j].second << " ";
}
// cout << endl;
}
dijkstra(1, x);
system("pause");
return 0;
}
我收到的错误是:
Error: Expression must have a class type.