#include <iostream>

class Timer {
private:
    int period = 0;

public:

    void setPeriod(int period) {
        this->period = period; //here the l value is the member and the r value is param
    }

    void log() {
        std::cout << "Timer Period: " << period << " ms" << std::endl;
    }
};

int main() {
    Timer t;
    int N;
    if (!(std::cin >> N)) return 0;

    for (int i = 0; i < N; ++i) {
        int p;
        std::cin >> p;
        t.setPeriod(p);
        t.log();
    }
    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

2 100 500

Expected Output

Timer Period: 100 ms Timer Period: 500 ms