June 2017
Intermediate to advanced
532 pages
12h 59m
English
We are going to write a program that is similar to the program we wrote in the unique_ptr recipe in order to get insights into the usage and principles of shared_ptr:
#include <iostream> #include <memory> using namespace std;
class Foo { public: string name; Foo(string n) : name{move(n)} { cout << "CTOR " << name << '\n'; } ~Foo() { cout << "DTOR " << name << '\n'; } };
Read now
Unlock full access