What I am trying to do:
- A function to add one to the current count.
- A function to subtract one from the current count.
- A function to reset the count to zero.
- A function that returns the current count.
Do not write a constructor for this class.
Write a main( ) function that uses this class
Your program should work as follows:
- Display your student information
- Create a Counter object.
- Write a loop that:
- Prompts the use with the following menu: 1 - add 1 to Counter
2 - subtract 1 from Counter
3 - display contents of Counter
4 - reset counter
5 - exit program
Does the class object go in the header file or is it okay here? What do I put in the header file? What I have so far, which is incomplete, but I want to see if I'm on the right track:
#include <iostream>
#include "counter.h"
using namespace std;
class Counter
{
public:
int myCounter()
void increment()
{
Count++;
}
void decrement()
{
Count--;
}
void display();
void resetCounter();
};
int main()
{
cout << "\nSelect from the following options: Type" << endl;
cout << "\n1 to increment the counter" << endl;
cout << "\n2 to decrement the counter" << endl;
cout << "\n3 to display the contents of the counter" << endl;
cout << "\n4 to reset the counter to zero" << endl;
cout << "\n5 to exit this program." << endl;
cout << "\nValid operators are 1 - 4 " << endl;
cin >> num1;
switch( num1 )
{
case'1':
increment(); break;
case'2':
decrement(); break;
case'3':
display(); break;
case'4':
resetCounter(); break;
case'5':
exit(1);
default:
cout <<"Error, not a valid operator."<<endl;
return 0;
}
void incCounter()
{