diff --git a/README.md b/README.md index 03c3422..481ab84 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ using namespace N; // Make T visible without N:: shared_ptr x; // Empty shared_ptr to a integer on heap. Uses reference counting for cleaning up objects. x = make_shared(12); // Allocate value 12 on heap shared_ptr y = x; // Copy shared_ptr, implicit changes reference count to 2. -cout << *y; // Deference y to print '12' +cout << *y; // Dereference y to print '12' if (y.get() == x.get()) { // Raw pointers (here x == y) cout << "Same"; } @@ -322,8 +322,8 @@ if (y == nullptr) { // Can compare against nullptr (here returns true) cout << "Empty"; } y = make_shared(15); // Assign new value -cout << *y; // Deference x to print '15' -cout << *x; // Deference x to print '12' +cout << *y; // Dereference x to print '15' +cout << *x; // Dereference x to print '12' weak_ptr w; // Create empty weak pointer w = y; // w has weak reference to y. if (shared_ptr s = w.lock()) { // Has to be copied into a shared_ptr before usage @@ -573,4 +573,4 @@ future fut = // result of async function async(launch::async, fib, 4); // start async function in other thread // do some other work cout << fut.get(); // get result of async function. Wait if needed. -``` \ No newline at end of file +``` diff --git a/cheatsheet-as-sourcefile.cpp b/cheatsheet-as-sourcefile.cpp index cbdba57..0d3dedd 100644 --- a/cheatsheet-as-sourcefile.cpp +++ b/cheatsheet-as-sourcefile.cpp @@ -295,7 +295,7 @@ using namespace N; // Make T visible without N:: shared_ptr x; // Empty shared_ptr to a integer on heap. Uses reference counting for cleaning up objects. x = make_shared(12); // Allocate value 12 on heap shared_ptr y = x; // Copy shared_ptr, implicit changes reference count to 2. -cout << *y; // Deference y to print '12' +cout << *y; // Dereference y to print '12' if (y.get() == x.get()) { // Raw pointers (here x == y) cout << "Same"; } @@ -307,8 +307,8 @@ if (y == nullptr) { // Can compare against nullptr (here returns true) cout << "Empty"; } y = make_shared(15); // Assign new value -cout << *y; // Deference x to print '15' -cout << *x; // Deference x to print '12' +cout << *y; // Dereference x to print '15' +cout << *x; // Dereference x to print '12' weak_ptr w; // Create empty weak pointer w = y; // w has weak reference to y. if (shared_ptr s = w.lock()) { // Has to be copied into a shared_ptr before usage @@ -527,4 +527,4 @@ thread t3(pingPongFn, "boing"); future fut = // result of async function async(launch::async, fib, 4); // start async function in other thread // do some other work -cout << fut.get(); // get result of async function. Wait if needed. \ No newline at end of file +cout << fut.get(); // get result of async function. Wait if needed.