Additional Information
C++ Pointers

Introduction

These are C++ tricks and tips I have found helpful. I call them C++ Pointers and I hope you'll find them useful too.

My C++ Pointers are licensed under the Creative Commons Attribution 4.0 International License. You should review the licence to determine your
rights to use and distribute

Summary of (and not a substitute for) the licence

You are free to,

  • Share - copy and redistribute the material in any medium or format
  • Adapt - remix, transform, and build upon the material

provided that you follow the following licence terms,

  • Attribution - You must give appropriate credit, provide a link to the licence, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • No additional restrictions - You may not apply legal terms or technological measures that legally restrict others from doing anything the licence permits.
my C++ Pointers. Commercial use of my C++ Pointers is allowed.
Be informed that they are provided with
NO WARRANTY

Section 5 Disclaimer of Warranties and Limitation of Liability.

  1. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
  2. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
  3. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
.

Available C++ Pointers

I have the following C++ Pointers

Pointer 1 - Objects, structs and STL Containers

All the literature (both on-line and textbooks) I referenced to learn how to use STL containers only showed how to use them to hold primitives, such as integers and strings, and made no mention of how to handle objects or structs stored in a container. This C++ Pointer demonstrates how objects and structs can be stored in STL Maps and Vectors.

Pointer 2 - When function and class variable names collide

The standard practice / recommendation on how to handle a name collision between a class variable and a function is to append an underscore '_' to the end of one of the variable names.

This advice is troublesome when you are adding a mutator member function to an existing class and the variable is widely used throughout the class. Also the resulting code is untidy with some variable names having underscores and the remainder being without.

This C++ pointer shows you how to have member function variables and class variables with same name.