Question
#include #include using namespace std; class Counter { private: int m_count; // counter value int m_stepSize; public: Counter() { m_count = 0; m_stepSize = 1;
#include
#include
using namespace std;
class Counter {
private:
int m_count; // counter value
int m_stepSize;
public:
Counter() { m_count = 0; m_stepSize = 1; }
Counter(int count, int stepSize);
int getCount();
void setCounter(int count, int step);
void getData(int& count, int& stepSize);
void incrementCount(); // increment by 1
void incrementCount(int step);
int getMaxCountValue(int threshold, int step);
static int getTotalCount(Counter* ptr, int numCounter);
};
int main() {
Counter c1(1, 2);
int ctr, ss;
c1.getData(ctr, ss);
cout
cout
cout
c1.incrementCount();
cout
c1.incrementCount(10);
cout
cout
cout
Counter c2;
c2.setCounter(10, 5);
int maxV = 49;
cout
Counter cArray[3];
cArray[0] = Counter(1, 1);
cArray[1] = Counter(5, 5);
cArray[2] = Counter(10, 1);
cout
getchar();
return 0;
}
Expected output The c1 counter value =1 The c1 counter step size : 2 Increment count by 2 Updated c1 count value = 3 Increment count by 10 Updated c1 count value = 13 f(k)= 10 + k*5 , find maximum value of f(k) such that f(k)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started