A
Alf P. Steinbach
Not yet perfect, but:
http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf
http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip
To access the table of contents, use the "Bookmarks" tab in Adobe
Acrobat.
Comments, corrections, praise, nits, etc., are still welcome!
1 Pointers.
1.1 Introduction to the basics.
1.1.1 How to obtain a pointer to a given object, and how to use that pointer.
1.1.2 The nullpointer value, valid and invalid pointers.
1.1.3 How to implement out-arguments by using pointers.
1.1.4 How to implement in-arguments by using pointers.
1.1.5 How to use C++ style references instead of C style pointers for arguments.
1.1.6 How to access main arguments.
1.1.7 Const-correctness for pointers and references.
1.2 Run-time polymorphism.
1.2.1 Polymorphism.
1.2.2 The concepts of data representations and linked data structures.
1.2.3 C-style polymorphism with simulated dynamic types (just one actual type).
1.2.4 Basic use of dynamic memory allocation & deallocation.
1.2.5 How to use function pointers to simulate dynamic types, C-style.
1.2.6 Using real types and inheritance for logical sub-types, mostly C-style.
1.2.7 Using vtables, mostly C-style (also a few words about abstract classes, etc.).
1.2.8 C++ virtual member functions.
1.2.9 C++ destructors and polymorphic delete.
1.3 Safety for dynamically allocated objects.
1.3.1 Object ownership and the C++ std::auto_ptr.
1.3.2 Exception safety for new: RAII and C++ constructors.
1.3.3 Ensure dynamic allocation by using C++ access specifiers & friendship.
1.3.4 An aside on wrapping boost::shared_ptr (a.k.a. std::tr1::shared_ptr).
1.3.5 Ensure that smart pointers are used, by overloading operator new.
1.3.6 Combat slicing by removing access to copy assignment.
1.3.7 Value copying problems & possible solutions.
1.3.8 Cloning as a solution to ownership and aliasing problems.
1.3.9 Intentional sharing as a solution to ownership and aliasing problems.
1.4 An introduction to exceptions.
1.4.1 How to generate and handle exceptions.
1.4.2 Exception usage example: conversion between numeric values and text.
1.4.3 Exceptions and pointers, including the concept of "hard" exceptions.
1.5 Basic serialization and de-serialization.
1.5.1 A serialization format for hierarchical data structures.
1.5.2 De-serialization: a simple non-OO recursive descent parser.
1.5.3 Serialization: a simple generator using intrusive OO code.
1.5.4 A generator using non-intrusive non-OO code (introducing C++ RTTI).
1.5.5 A generator using non-intrusive OO code (introducing the visitor pattern).
1.6 Notes on C++ inheritance as it pertains to pointers.
1.6.1 Passing Base/Derived-class pointers by reference.
1.6.2 The Liskov substitution principle (more about mutable/immutable).
1.6.3 Covariance, contravariance and invariance.
1.7 Closing words & acknowledgements.
http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf
http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip
To access the table of contents, use the "Bookmarks" tab in Adobe
Acrobat.
Comments, corrections, praise, nits, etc., are still welcome!
1 Pointers.
1.1 Introduction to the basics.
1.1.1 How to obtain a pointer to a given object, and how to use that pointer.
1.1.2 The nullpointer value, valid and invalid pointers.
1.1.3 How to implement out-arguments by using pointers.
1.1.4 How to implement in-arguments by using pointers.
1.1.5 How to use C++ style references instead of C style pointers for arguments.
1.1.6 How to access main arguments.
1.1.7 Const-correctness for pointers and references.
1.2 Run-time polymorphism.
1.2.1 Polymorphism.
1.2.2 The concepts of data representations and linked data structures.
1.2.3 C-style polymorphism with simulated dynamic types (just one actual type).
1.2.4 Basic use of dynamic memory allocation & deallocation.
1.2.5 How to use function pointers to simulate dynamic types, C-style.
1.2.6 Using real types and inheritance for logical sub-types, mostly C-style.
1.2.7 Using vtables, mostly C-style (also a few words about abstract classes, etc.).
1.2.8 C++ virtual member functions.
1.2.9 C++ destructors and polymorphic delete.
1.3 Safety for dynamically allocated objects.
1.3.1 Object ownership and the C++ std::auto_ptr.
1.3.2 Exception safety for new: RAII and C++ constructors.
1.3.3 Ensure dynamic allocation by using C++ access specifiers & friendship.
1.3.4 An aside on wrapping boost::shared_ptr (a.k.a. std::tr1::shared_ptr).
1.3.5 Ensure that smart pointers are used, by overloading operator new.
1.3.6 Combat slicing by removing access to copy assignment.
1.3.7 Value copying problems & possible solutions.
1.3.8 Cloning as a solution to ownership and aliasing problems.
1.3.9 Intentional sharing as a solution to ownership and aliasing problems.
1.4 An introduction to exceptions.
1.4.1 How to generate and handle exceptions.
1.4.2 Exception usage example: conversion between numeric values and text.
1.4.3 Exceptions and pointers, including the concept of "hard" exceptions.
1.5 Basic serialization and de-serialization.
1.5.1 A serialization format for hierarchical data structures.
1.5.2 De-serialization: a simple non-OO recursive descent parser.
1.5.3 Serialization: a simple generator using intrusive OO code.
1.5.4 A generator using non-intrusive non-OO code (introducing C++ RTTI).
1.5.5 A generator using non-intrusive OO code (introducing the visitor pattern).
1.6 Notes on C++ inheritance as it pertains to pointers.
1.6.1 Passing Base/Derived-class pointers by reference.
1.6.2 The Liskov substitution principle (more about mutable/immutable).
1.6.3 Covariance, contravariance and invariance.
1.7 Closing words & acknowledgements.