- Category:
- CSharp
- Tags:
-
- File Size:
- 1kb
- Update:
- 2017-12-23
- Downloads:
- 0 Times
- Uploaded by:
- 俞智灏
Description: Define a class named CounterType. The object of this class is used for counting, recording a non negative integer. Write a default constructor for this class. It can set the counter to 0, and then write a constructor, which receives a parameter, which is used to set the counter to the value specified by the parameter. Two member functions are written to increase the count by 1 and decrease by 1 respectively. Make sure that any member function does not allow the counter to be negative. The member function void reset (); can reset the value of the counter to 0 at any time. Two member functions are written, one returns the value of the current counter, and the other outputs the counter value to a stream. The output function has a ostream type formal parameter (when called, the actual parameter can be cout). Consider which member functions are defined as regular member functions.
Define the main function and test the class.
To Search:
File list (Check if you may need any files):
Filename | Size | Date |
---|
counter.c | 507 | 2017-12-23
|
counter.h | 507 | 2017-12-23
|
ReadMe.txt | 1250 | 2017-12-23 |