online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <string> #include <map> int w = 20; int h = 20; class RawGrid { public: RawGrid(int w, int h) { width = w; data = new bool*[w]; for(int x = 0; x < width; x++) data[x] = new bool[h]; } ~RawGrid() { if (data) { for(int x = 0; x < width; x++) delete[] (data[x]); delete[] data; } } private: int width; bool** data = nullptr; }; int main() { std::cout<<"Test A" << std::endl; { RawGrid grid_a(w, h); std::cout<<"Reserved memory" << std::endl; } std::cout<<"Deleted memory" << std::endl; // because grid_a is out of scope std::cout<<"Test B" << std::endl; RawGrid grid_a(w, h); RawGrid grid_b(w, h); std::map<int, RawGrid> cache_map; cache_map.emplace(0, grid_a); cache_map.emplace(1, grid_b); std::cout<<"Reserved memory" << std::endl; cache_map.clear(); std::cout<<"Deleted memory" << std::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