try
cout<<"hi "<<c<<endl; //*c is a single character. cout understands char* to be a string type
and fix this bug
strcpy(c,'\0');}
strcpy takes a c-string, not a single character ('\0' is one character).
instead just use c[0] = 0; (or type 4 chars for 1 if you pref '\0')
the forum compiler gave your expected results with those changes.
Last edited on
Also note that your operator+ needs to allocate extra space to concatenate the string.