Advertisement
hnOsmium0001

Untitled

Oct 9th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. // This file is a "Hello, world!" in C++ language by GCC for wandbox.
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <thread>
  5. #include <vector>
  6. class FooBase
  7. {
  8. virtual void OnStateChange() = 0;
  9. };
  10.  
  11. class FooBaseImpl : public FooBase {
  12. void OnstateChange() override {
  13. // stuff in static stateChange();
  14. }
  15. };
  16.  
  17. class FooImpl : public FooBase
  18. {
  19. void OnStateChange() { .. }
  20. };
  21.  
  22. class Bar
  23. {
  24. Bar() {
  25. static FooBaseImpl impl
  26. foovec.push_back(&impl);
  27. }
  28.  
  29. void test() {
  30. Foo::stateChange();
  31. for(f : foovec) f->OnStateChange();
  32. }
  33. vector<FooBase*> foovec;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement