/****************************************************************************** *** FILE: error_flag.cpp *** DATE: 03/17/2004 *** AUTHOR: Daniel Dementiev *** GOAL: This program illustrates how no litle error checking or can cause *** a damage to the data. Pay attention to the method Array::Item() *** we check that the value of the index argument is valid, but we *** just set an error flag. ******************************************************************************/ #include using namespace std; class Array { private: int count; int data[10]; int size; bool error; public: Array() : count(0), size(10), error(false) {}; int Count() const { return count; }; int Size() const { return size; }; bool Error(); int& Item(int index); }; int& Array::Item(int index) { error = index<0 || index>=10 ; return data[index]; } bool Array::Error() { bool err = error; error = false; return err; } void main() { Array a; cout<<"count = "<