Hi, I'm learning cpp and In my last assignment I am rewriting the std::string class. so here is an outline of my code: string class:
   class String {
    public:
     String(const char* sInput) {
      string = const_cast<char*> (sInput);    
     }
     const String operator+(const char* str) {
         //snip
            print();
     }
     void print() {
         cout<<string;
     }
     int search(char* str) {
     }
    private:
     char* string;
     int len;
};
Oh and I have to say I tried to declare the method as String* operator+(const char* str) and as const String& operator+(const char* str) with no change. And here is how I run it:
int main(int argc, char* argv[]) {
    String* testing = new String("Hello, "); //works
    testing->print();//works
    /*String* a = */testing+"World!";//Error here.
return 0;
}
The full error goes like such:
foobar.cc:13: error: invalid operands of types ‘String*’ and ‘const char [7]’ to binary ‘operator+’
I looked up on Google and in the book I am learning from with no success. any one with suggestions? (I am pretty sure I am doing something foolish you will have to forgive me I am originally a PHP programmer) can any one point me to what am I missing?