online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <iostream> using namespace std; template<typename T> class stupid_tree{ struct Node{ Node(){} T val; Node * left; Node * right; }; Node * root = nullptr; void print_helper(Node *node){ if(!node){ return; } print_helper(node->left); std::cout << node->val << " "; print_helper(node->right); } public: stupid_tree(){} void insert(T val){ Node *new_node; if(!root){ root = new Node; new_node = root; } else{ auto cur = root; while(true){ if(val < cur->val){ if(cur->left){ cur = cur->left; } else{ cur->left = new Node; new_node = cur->left; break; } } else{ if(cur->right){ cur = cur->right; } else{ cur->right = new Node; new_node = cur->right; break; } } } } new_node->val = val; } void print(){ if(!root){ cout << "empty tree\n"; } else{ print_helper(root); } } }; int main() { stupid_tree<int> tree; tree.insert(4); tree.insert(6); tree.insert(1); tree.insert(5); tree.insert(2); tree.insert(3); tree.insert(0); tree.print(); 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