online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <cstring> using std::cout; using std::endl; class forlab { public: std::string name; int size; int* arr; forlab(std::string name, int size) { this->size = size; this->name = name; *&arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = 0; } } forlab(const forlab& f) { size = f.size; name = f.name; arr = new int[size]; // заново выделяем память memcpy(arr, f.arr, sizeof(int) * size); // копируем весь массив } forlab() { this->name = ""; this->size = 0; this->arr = 0; } ~forlab() { delete [] this->arr; } int& operator[] (const int index); friend forlab operator+(const forlab a,const forlab b); void show() { for (int i = 0; i < size; i++) { cout << this->arr[i] << " "; } } }; int& forlab::operator[] (const int index) { return this->arr[index]; } forlab operator+(const forlab a, const forlab b) { forlab temp("", a.size+b.size); for (int i = 0; i < a.size; i++) { temp.arr[i] = a.arr[i]; } int counter = a.size; for (int i = 0; i < b.size; i++) { temp.arr[counter] = b.arr[i]; counter++; } return temp; } int main() { forlab ex1("first", 15); forlab ex2("second", 20); forlab ex3 = ex1 + ex2; ex3.show(); 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