Search code examples
c++stlencapsulation

Vector, Size_type, and Encapsulation


I have a class with a private data member of type vector< A*>.

The class has two public methods that actually use vector<A*>::size_type:

  1. Method returning number of elements in the vector
  2. Method returning element in the vector by index

I can add to public section of the class the following typedef:

typedef vector::size_type SIZE_t;

but IMHO it exposes too many details about class implementation.

Another approach is to use size_t.

What do you think?


Solution

  • Use plain old size_t for both member functions.