MCPcopy Create free account
hub / github.com/Apress/design-patterns-in-modern-cpp / smart_pointers

Function smart_pointers

Structural/Proxy/proxy.cpp:89–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void smart_pointers()
90{
91 BankAccount* a = new CurrentAccount(123);
92 a->deposit(321);
93 delete a;
94
95 // << will not work if you make this a shared_ptr<BankAccount>
96 auto b = make_shared<CurrentAccount>(123);
97
98 BankAccount* actual = b.get(); // pointer's own operations on a .
99 b->deposit(321); // underlying object's operations are on ->
100 // note this expression is identical to what's above
101 cout << *b << endl;
102 // no delete
103
104 // see shared_ptr in file structure window
105}
106
107struct Pingable
108{

Callers

nothing calls this directly

Calls 2

depositMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected