fork(5) download
  1. #include <vector>
  2.  
  3. class TimerFriend
  4. {
  5. public:
  6. TimerFriend(const TimerFriend&) = default;
  7. TimerFriend& operator =(const TimerFriend&) = default;
  8.  
  9. private:
  10. TimerFriend() {}
  11.  
  12. friend class Timer;
  13. };
  14.  
  15. class Timer {
  16. private:
  17. int timeLeft;
  18.  
  19. public:
  20. Timer(unsigned int ms, const TimerFriend&) : timeLeft(ms) {}
  21.  
  22. static std::vector<Timer> instances;
  23. static void create(unsigned int ms) {
  24. instances.emplace_back(ms, TimerFriend());
  25. }
  26. };
  27.  
  28. std::vector<Timer> Timer::instances;
  29.  
  30. int main()
  31. {
  32. Timer::create(100);
  33. }
Success #stdin #stdout 0s 3024KB
stdin
Standard input is empty
stdout
Standard output is empty