previous | start | next

2.3 Template version of intArray

If we created the new intArray for LineItem data, we would have a naming problem. We would have to create a name like

Instead of doing that, we can write the code once for a class named Array, but add a type "parameter".

When the Array is created, we provide a type name or expression for this parameter. For example:

 Array<int>  arr1;      // Array of integers
 Array<LineItem> arr2;   // Array of LineItem's


previous | start | next