Difference between size_t and size_type

here are two code example that I've found.

1
2
3
4
5
string str;
for(string::size_type i=0; i < str.length(); i++)
    {
      str[i] = toupper (str[i]);
    }


1
2
3
4
5
   vector<int> myvector;
  for(size_t i=0; i < myvector.size()-1; i++)
    {
        cout << myvector[i];
    }
The std::string::size_type is a member type.
http://www.cplusplus.com/reference/string/string/

There is a std::vector::size_type too:
http://www.cplusplus.com/reference/vector/vector/

The std::size_t is a stand-alone type definition/alias.
You can think about std::size_t as ::size_type for C arrays.
Topic archived. No new replies allowed.