const bei Stringübergabe
-
Hallo wieso geht das obere Beispiel nur ohne const während das untere mit const geht?
1 Beispiel
String::String(char *pStr /* = "" */)
{
this->pString = pStr;
}2 Beispiel
String::String(const char *pStr /* = "" */)
{
pString = new char[strlen(pStr) + 1];
strcpy(pString, pStr);
}
-
vielleicht weil this->pString auch nicht const ist?
Und weil strcpy als 2tes Argument einen const char* will?
