June 2017
Intermediate to advanced
532 pages
12h 59m
English
We will write a program that shows us how unique_ptr handles memory by creating a custom type that adds some debug messages upon its construction and destruction. Then, we will play around with unique pointers, maintaining dynamically allocated instances of it:
#include <iostream> #include <memory> using namespace std;
class Foo { public: string name; Foo(string n) : name{move(n)} { cout << "CTOR " << name << '\n'; } ~Foo() ...Read now
Unlock full access