Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Copy this class declaration below into the top of your main.cpp file. The Button

ID: 440714 • Letter: C

Question

Copy this class declaration below into the top of your main.cpp file. The Button class represents a physical button. All it does is keep track of the number of times it has been pressed. class Button { private: int pressCount; // starts at 0 public : // CONSTRUCTOR Button(); // MUTATOR void Press(); // increments the pressCount // ACCESSOR int timesPressed(); }; Then do each of these steps: Write the definitions of the three member functions. Place this code below main(). Inside main(), create a single new variable of type Button. Then, add code that calls its mutator and accessor functions to demonstrate that it works as expected.

Explanation / Answer

#include #include using namespace std; class Button{ private: //not really necessary here since it is private by default for classes in Cpp pressCount;//starts at 0 public: //CONSTRUCTOR Button(); //MUTATOR void Press();//increments the pressCount //ACCESSOR int TimesPressed(); }; int main(){ Button test; cout