Program to define a class - PP5
Posted on 2005-05-10
Defines and tests class CounterType, which is used to count things.
CounterType contains both a default constructor and a constructor that
sets the count to a specified value, plus methods to increment, decrement,
return, and output the count. The count is always nonnegative.
This is the program:
using namespace std;
//Initializes the count to 0.
//Precondition: initCount holds the initial value for the count.
// If initCount > 0,initializes the count to initCount.
// If initCount <= 0,initializes the count to 0.
// The count is one more than it was.
// If the count was positive, it is now one less than it was.
// If the count was 0, it is still 0
void output(ostream& outStream);
//Precondition: outStream is ready to write to
//Postcondition: count has been written to outStream
count = 0;
if (initCount >= 0)
count = initCount;
count = 0;
if (count > 0)
void CounterType::output(ostream& outStream)
outStream << count;
I dont know what is missing on this program that's why i cant run this program? Can someone help me. Thanks