fork(2) download
  1. #include <iostream>
  2.  
  3. class Screen
  4. {
  5. public:
  6. void some_member () const;
  7. size_t get() const { return access_ctr; }
  8. private:
  9. mutable size_t access_ctr = 0;
  10. };
  11.  
  12. void Screen::some_member () const
  13. {
  14. ++access_ctr;
  15. }
  16.  
  17. int main()
  18. {
  19. const Screen s;
  20. for (int i = 0; i < 5; ++i)
  21. {
  22. s.some_member();
  23. std::cout << s.get() << std::endl;
  24. }
  25. }
  26.  
  27.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1
2
3
4
5