fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <random>
  5. #include <memory>
  6.  
  7. class BaseRandom
  8. {
  9. public:
  10. virtual int next_int() = 0;
  11. };
  12.  
  13. template <class T>
  14. class ConcreteRandom : public BaseRandom
  15. {
  16. public:
  17. virtual int next_int() {
  18. return prng();
  19. }
  20.  
  21. T prng;
  22. };
  23.  
  24. int main() {
  25. auto random = std::make_unique<ConcreteRandom<std::mt19937>>();
  26. random->next_int();
  27. return 0;
  28. }
Success #stdin #stdout 0s 4208KB
stdin
Standard input is empty
stdout
Standard output is empty