Question: This practice problem will require you to implement member functions of a class. This question is similar to demo3 of handout H804. Given class declaration

This practice problem will require you to implement member functions of a class.

This question is similar to demo3 of handout H804. Given class declaration for CountDown, you are required to implement it's member functions. In addition, you will also need to write your own main.cpp to test your implementation.

The header to be used must be called p023.h with the following content:

Copy

#ifndef _P023

#define _P023

class CountDown {

int count;

public:

CountDown(int val);

void reset(int val);

void doCount();

};

#endif

Here, ifndef is a conditional preprocessor macro to ensure the same header does not get included twice, which will cause compiler errors saying duplicated class declaration.

The three member functions should do the following things:

The constructor should initialise the value of that object's count value to val.

reset should set the value of that object's count value to val.

doCount check if count's value is 0. If it is, output in a single line Counting ends! Bling bling bling!. If it is not, output Counting:, then the value of count, make the value of count one less (-1).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!