I have a class like this :
class Foo { public: Foo() { for(int i = 0; i < 10; ++i) v.push_back(i); }; const vector<
Since foo is not const compiler is trying to use the non-const method. As a workaround you can do the following:
foo
const
Foo foo; const Foo& cFoo = foo; for(int i = 0; i < (int) cFoo.V().size(); ++i) cout << cFoo.V().at(i) << endl;