online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include<cstring> #include<string> #include<vector> using namespace std; class String { char* array; public: String(const char* s) { array = new char[strlen(s) + 1]{ '\0' }; strcpy(array, s); } ~String() { if (array) { delete[]array; } } String operator+ (const char* p) //返回对象 { String temp(p); char* tempStr = temp.array; temp.array = new char[strlen(array) + strlen(tempStr) + 1]{ '\0' }; strcpy(temp.array, array); strcat(temp.array, p); return temp; } friend ostream& operator<<(ostream& output,const String& x); // <<函数重载只能定义成友元 }; ostream& operator << (ostream& output,const String& x) //对<<重载的方式 { output << x.array; return output; } int main() { String string1("mystring"); cout << string1 + "ab" << endl; cout << string1 << endl; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue