Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. class Utl
  5. {
  6. public:
  7.  
  8. // singleton accessor
  9. static Utl& GetInstance();
  10.  
  11. virtual std::string GetHello( bool full ) = 0;
  12. };
  13.  
  14. class UtlImpl : public Utl
  15. {
  16. public:
  17. UtlImpl() {}
  18.  
  19. virtual std::string GetHello( bool full )
  20. {
  21. return (full)?"full":"partial";
  22. }
  23. };
  24.  
  25. Utl& Utl::GetInstance()
  26. {
  27. static UtlImpl instance;
  28. return instance;
  29. }
  30.  
  31. int main( int argc, char* argv[] )
  32. {
  33. std::cout << Utl::GetInstance().GetHello(true) << std::endl;
  34. std::cout << Utl::GetInstance().GetHello(false) << std::endl;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement