Operator Overloading - Can This Be Done?
I just had a go at overloading the + operator. It works, but I want it to do more if possible. For example if i do this in my code:
It concatenates the two, but if I do:
something + " together";
It wont work. Is there any way I can get what side of the operator the constant char pointer is on and whack it on the string accordingly?
"I want to put " + something;
Heres my function so far:
String &String::operator+(const char *add)
char *origin = str_ptr;
str_ptr = new char[size];
char *src = origin;
char *dst = str_ptr;
while(*src) *dst=*src, src++, dst++; //Copy original
while(*add) *dst=*add, add++, dst++; //Copy string to add