/****************************************************************************** *** FILE: special_value.cpp *** DATE: 03/17/2004 *** AUTHOR: Daniel Dementiev *** GOAL: This program illustrates how to use 'special value' technique *** for error checking. Please note that unlike other examples *** method Array::Item() returns an integer, not a reference to an *** integer. We need to do this because we cannot return a reference *** to a integer constant ( like return -1; ) ******************************************************************************/ #include using namespace std; class Array { private: int count; int data[10]; int size; public: Array() : count(0), size(10) {}; int Count() const { return count; }; int Size() const { return size; }; int Item(int index); }; int Array::Item(int index) { if( index<0 || index>=10 ) return -1; return data[index]; } void main() { Array a; cout<<"count = "<