Calling the delete operator is as simple as using the keyword delete and the pointer which points to the object to be deleted. The compiler automatically determines the amount of memory which is being released based on the type of object being deleted. Type-safety is the ability for the compiler to match pointers to the type of data which they are pointing to. For example it is possible to put an integer on a linked list, and then when taking it off cast it to a character. This casting would not be caught by the compiler, and can lead to very hard to find bugs.
Templates allow a programmer to create objects like linked lists which are type-safe.
Templates work by allowing the instantiation of an object to specify what class of objects it can interface with. For example a templated link list could specify that it is for integers, the compiler would then catch any attempts to manipulate the list with anything but an integer. Templating is like creating separate code for each data type that you want to interface with, without the hassle. The following code is a modified version of the earlier Node class. This code has the new keyword template .