online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <memory> int functionFoo (int var) { // Method 1: assign value while allocation std::unique_ptr<int> uptr = std::make_unique<int>(var); std::cout << "Variable is " << var << " uptr addr " << uptr.get() << " value " << *uptr << std::endl; // Method 2: assigning value to unique_ptr's ptr std::unique_ptr<int> uptr2 = std::make_unique<int>(); *uptr2 = var; std::cout << "Variable is " << var << " uptr2 addr " << uptr2.get() << " value " << *uptr2 << std::endl; *uptr2 += 20; std::cout << "Value changed \n" << "uptr2 addr " << uptr2.get() << " value " << *uptr2 << std::endl; // Method 3: using move std::unique_ptr<int> uptr3 = std::move(uptr); std::cout << "Variable is " << var << " uptr3 addr " << uptr3.get() << " value " << *uptr3 << std::endl; std::cout << "\nAccessing uptr \n" << "uptr addr " << uptr.get() << std::endl; // Method 4: allocate unique_ptr and assign to auto auto uptr4 = std::make_unique<int>(var); std::cout << "Variable is " << var << " uptr4 addr " << *uptr4 << std::endl; int res = *uptr2; res += 1; std::cout << " res " << res << std::endl; return res; } int main() { int ret = functionFoo(23); std::cout << "return " << ret << 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