const object and const constructor

Posted by Muhammad alaa on Stack Overflow See other posts from Stack Overflow or by Muhammad alaa
Published on 2010-06-03T20:56:33Z Indexed on 2010/06/03 21:04 UTC
Read the original article Hit count: 297

Filed under:

Is there any way to know if an object is a const object or regular object, for instance consider the following class

class String
{
   String(const char* str);
};

if user create a const object from String then there is no reason to copy the passed native string and that because he will not make any manipulation on it, the only thing he will do is get string size, string search and other functions that will not change the string.

© Stack Overflow or respective owner

Related posts about c++