// File Name: countv1.cpp // Author: Xiannong Meng // Course: CS2330 // Date: March 15, 1997 // Problem statement: demonstrate how class is defined #include #include #include "countv1.h" // class constructor // Intent: initialize a class instant (object) // Precondition: none // Postcondition: initial value is assigned CounterV1::CounterV1() { value = 0; } // Name: Increment // Intent: Increment the value of counter by one // Precondition: a counter has been defined // Postcondition: value is incremented by one void CounterV1::Increment() { if (value == INT_MAX) // another possible action is to reset counter to zero cerr << " value exceeding limit ... \n"; else value ++; } // Name: Display // Intent: Display the value of the counter // Precondition: a counter has been defined // Postcondition: value is displayed void CounterV1::Display() { cout << "Value of the counter is " << value << endl; }