June 2017
Intermediate to advanced
532 pages
12h 59m
English
In this section, we will define a type that cannot be allocated with new directly and, also, cannot be released again using delete. As this prevents it from being used with smart pointers directly, we perform the necessary little adaptions to instances of unique_ptr and smart_ptr:
#include <iostream> #include <memory> #include <string> using namespace std;
class Foo { string name; Foo(string n) : name{n} { cout << "CTOR ...Read now
Unlock full access