how overloading operator + for literal strings?

i have 1 nice write() function:
1
2
3
4
5
6
7
8
9
10
11
void write()
    {
        cout <<"";
    }

    template <typename A, typename ...B>
    void write(A argHead, B... argTail)
    {
        cout << argHead;
        write(argTail...);
    }

thes e function works. but if i concat literal strings with '+', i must use '(string)'. so i'm trying overload the operator + for concat literal strings, but without sucess:(

1
2
3
4
5
6
string operator + ( char *value1)
    {
        string value2;
        value2=(string) value2+value1;
        return value2;
    }

(these functions are inside of my Console class)
what i'm doing wrong?
Last edited on
You cannot overload operator+ to work with two char* because you are not allowed to overload operators without at least one of the parameters being a user-created type. You could, if you wanted, just make a named function that does the same thing, but then I'd ask why you aren't just using strcat().
what i want is just use the '+'(in my write function) for concat the chars and avoiding the '(string)';)
there is another way for do it?
Topic archived. No new replies allowed.