This demo illustrates how pointers and references are used in C++ code.
We've demonstrated std::unique_ptr and std::shared_ptr as well as native
pointers.
PointersAndReferences.txt
Demonstrating Pointers and References
=======================================
declare instance of custom class Demo
---------------------------------------
#1 demo
declare and use pointer to demo
---------------------------------
#2 demo
declare and use reference to demo
-----------------------------------
#3 demo
declare and use pointer to Demo instance on heap
--------------------------------------------------
#4 demo on heap
destroying demo on heap
declare and use reference to Demo instance on heap
----------------------------------------------------
#5 demo on heap
destroying demo on heap
you can declare and use reference to reference to a temporary
---------------------------------------------------------------
#6 another Demo instance
declare a unique_ptr to refer to heap allocation with automatic destruction
-----------------------------------------------------------------------------
#7 referenced by std::unique_ptr
declare a shared_ptr sharing a reference counted heap allocation
------------------------------------------------------------------
#8 demo referenced by std::shared_ptr sPtr1
declare a shared_ptr sharing a reference counted heap allocation
------------------------------------------------------------------
#9 demo referenced by std::shared_ptr sPtr2
---- end of main ----
destroying demo referenced by std::shared_ptr sPtr2
destroying referenced by std::unique_ptr
destroying another Demo instance
destroying demo
note order of destruction
Press any key to continue . . .