PsiX posted:
const int DoSth();
Firstly, it has no effect if you apply it to a built-in type, because return-
by-value results in an R-value in anyway (which can't be assigned to).
If applied to a user-defined type, you won't be able to invoke any non-
const member functions:
Func().SomeNonConstMemberFunc(); /* Compiler ERROR */
I myself use const return values to serve as a reminder to the programmer
that he/she should keep track of the return value (e.g. for dynamic memory
allocation):
char *const Str()
{
char *const p = new char[30];
strcpy(p,"Monday the 5th of August");
return p;
}
--
Frederick Gotham