I was wondering is it possible to override the addition operator so that it will take two constants of type char*.
I tried writing the following code but it only gave me an error message stating "'operator +' must have at least one formal parameter of class type".
So, is it fundamentally impossible to override this operator outside a user defined class, or is there a way to do it?Code:
char* operator+(const char* left, const char* right)
char* c, *d;
d = new char[strlen(left) + 1];
c = new char[strlen(left) + strlen(right) + 1];
c = strcat(d, right);
If so, how?