May 2012
Intermediate to advanced
679 pages
16h 56m
English
Arrays in C++ do not check for bounds. It creates many bugs. It will be a nice idea if program aborts, when array is accessed out of bounds. An array can be of any type. If we do not want to write separate routines for every type, a template class is the only solution.
Problem: Write a program to create class to implement a “Safe Array”. It should be using template <class T>.
Solution: For simplicity, let us fix size of an array as 100. Let us define a class Sarray. Rules for this class are as follows.
Read now
Unlock full access