Tuesday, June 24, 2008

string::size_type

C++ Primer 4/e in 3.2.3. Operations on strings there is a best practice :『Any variable used to store the result from the string size operation ought to be of type string::size_type. It is particularly important not to assign the return from size to an int.』
Chinese translation is said :『任何用以存放string size()返回值的變數都應該是string::size_type型別。千萬別把size()返回值賦予一個int變數,切記。』
I record in my blog then I don't forget.

achi's Blog

No comments: