I guess this is a very basic question.
when I declare a vector of const pointers, like this:
vector<const SomeClass*> vec;
Is it a declaration that the pointers are const or the objects that are pointed to by the array element?
thanks
I guess this is a very basic question.
when I declare a vector of const pointers, like this:
vector<const SomeClass*> vec;
Is it a declaration that the pointers are const or the objects that are pointed to by the array element?
thanks
 
    
    vector<const SomeClass*> vec;
It's declaring a vector containing pointers to const objects of type SomeClass.
 
    
    There are two places the const could go:
T* p1;                  // non-const pointer, non-const object
T const* p2;            // non-const pointer, const object
T* const p3;            // const pointer, non-const object
T const* const p4;      // const pointer, const object
Just read from right-to-left. For this reason, it becomes clearer if you write types as T const instead of const T (although in my code personally I still prefer const T). 
You are specifically constructing a vector of pointers to const objects. Note that you could not create a vector of const pointers, since a vector requires its elements to be copyable (or, in C++11, at least movable) and a const pointer is neither.
