samedi 28 mars 2015

C++: How can I get the number of characters in a std::string without calling any of the methods in the C++ string class?

For example, how can I write a function like this:



int countChar(std::string str);


to count the number of chars in the str? I can't use any of the methods in std::string class, like str[i] != '\0'; or str.length().


Thanks!


Aucun commentaire:

Enregistrer un commentaire