fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct TypeX {};
  4. struct TypeY {};
  5.  
  6. class A {
  7. public:
  8. A(TypeX a)
  9. {
  10. /* initialize using TypeX */
  11. }
  12. A(TypeY a)
  13. {
  14. /* initialize using TypeY */
  15. }
  16. };
  17.  
  18.  
  19. class B {
  20. private:
  21. A a;
  22. static const TypeX x;
  23. static const TypeY y;
  24.  
  25. public:
  26. B(bool useTypeX)
  27. : a(useTypeX ? A(x) : A(y))
  28. {}
  29. };
  30.  
  31. const TypeX B::x;
  32. const TypeY B::y;
  33. int main() {
  34. // your code goes here
  35. return 0;
  36. }
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty