Reputation: 1323
I have the following code:
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct node{
vector<int> vic;
bool visitato = false;
};
int main (){
vector<node> grafo;
ifstream in("input.txt");
int n, m, s, from, to;
in >> n >> m >> s;
grafo.resize(n);
for (int i = 0; i < m; i++){
in >> from >> to;
grafo[from].vic.push_back(to);
}
for (int i = 0; i < grafo.size(); i++)
for(int j = 0; j < grafo[i].vic.size(); j++)
cout << "From node " << i << " to node " << grafo[i].vic[j] << endl;
}
And (on Ubuntu) I type the following command:
/usr/bin/g++ -DEVAL -static -O2 -o visita visita.cpp -std=c++0x
And I get the following error:
visita.cpp:10:21: sorry, unimplemented: non-static data member initializers
visita.cpp:10:21: error: ISO C++ forbids in-class initialization of non-const static member ‘visitato’
At my home it works fine but here in the university it doesn't. The command to executed has been posted by our teacher. Then why doesn't it work in the uni but it does in my home?
Upvotes: 1
Views: 3532
Reputation: 1323
Solved with this code:
struct node{
vector<int> vic;
bool visitato;
node() : visitato(false) {}
};
Upvotes: 2