{}

Build your resume with HTML & CSS and win $100

Get featured on Programiz PRO and the Wall of Inspiration.

Build your resume with HTML & CSS and win $100

Join Challenge →
Join Challenge →

Build your resume with HTML & CSS and win $100

Get featured on Programiz PRO and the Wall of Inspiration.

Build your resume with HTML & CSS and win $100

Join Challenge →
Join Challenge →
run-icon
main.cpp
// Online C++ compiler to run C++ program online #include <iostream> struct Test { Test() { std::cout << "Allocating\n"; a = new int(5); } ~Test() { std::cout << "Deallocating\n"; delete a; a = nullptr; } int* a; }; struct ArrayTest { void write(Test const & test) { a[0] = test; } Test a[1]; }; int main() { // Write C++ code here std::cout << "Creates empty default Test\n"; ArrayTest a{}; std::cout << "Creates Test b\n"; Test b{}; std::cout << "Creates Test c\n"; Test c{}; std::cout << "Copies b into ArrayTest\n"; a.write(b); std::cout << "Overwrites b with c in ArrayTest. Should deconstructor b\n"; a.write(c); std::cout << "Deallocated end of scope\n"; return 0; }
Output