fork download
  1. #include <iostream>
  2.  
  3. #include <string>
  4. #include <tuple>
  5.  
  6. class Type
  7. {
  8. public:
  9. Type() : t{std::tie(a, b, c, d, e, f)} {}
  10.  
  11. int a;
  12. short b;
  13. long c;
  14. unsigned char d;
  15. bool e;
  16. std::string f;
  17.  
  18. std::tuple<int&, short&, long&, unsigned char&, bool&, std::string&> t;
  19. };
  20.  
  21. int main()
  22. {
  23. Type A{};
  24.  
  25. A.c = 5;
  26.  
  27. std::cout << std::get<2>(A.t) << std::endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
5