const vector implies const elements?
Does const vector<A> mean that its elements are constas well? In the code below, v[0].set (1234); in void g ( const vector<A> & v ) produces the compiler error const.cpp:28:3: error: member function 'set' not viable: 'this' argument has type 'const value_type' (aka 'const A'), but function is not marked const Why? But (*v[0]).set(1234); in void h ( const vector<A *> & v ) is OK for the compiler. What's the difference between the versions? // ........................................................... class A { private: int a; public: A (int a_) : a (a_) { } int get () const { return a; } void
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.