Exceptions and member functions
Up to this point in the tutorial, you’ve only seen exceptions used in non-member functions. However, exceptions are equally useful in member functions, and even moreso in overloaded operators. Consider the following overloaded [] operator as part of a simple integer array class:
1 2 3 4 |
int& IntArray::operator[](const int index) { return m_data[index]; } |
Although this function will work great as . . . → Read More: 20.5 — Exceptions, classes, and inheritance