#include<iostream> using namespace std; class DeviceCounter { private: int count; public: DeviceCounter(int m): count(m) { } DeviceCounter():count(0) { } int getCounterValue() const { return count; } int operator++() { return ++count; } }; int main() { int n; cin>>n; DeviceCounter counter; for(int i=0;i<n;i++) { ++counter; } cout<<"Final count="<<counter.getCounterValue(); }
Test Cases
Test Results
Input
3
Expected Output
Final count=3