fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. tuple<int,int,int> tuple1; //creates tuple of integers
  6. tuple<int,string,string> tuple2; // creates pair of an integer an 2 string
  7.  
  8. tuple1 = make_tuple(1,2,3); // insert 1, 2 and 3 to the tuple1
  9. tuple2 = make_pair(1,"Studytonight","Loves You");
  10. /* insert 1, "Studytonight" and "Loves You" in tuple2 */
  11.  
  12. int id;
  13. string first_name, last_name;
  14.  
  15. tie(id,first_name,last_name) = pair2;
  16. /* ties id, first_name, last_name to
  17.   first, second and third element of tuple2 */
  18.  
  19. cout << id <<" "<< first_name <<" "<< last_name;
  20. /* prints 1 Studytonight Loves You */
  21.  
  22. return 0;
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9:51: error: no matching function for call to ‘make_pair(int, const char [13], const char [10])’
    tuple2 = make_pair(1,"Studytonight","Loves You");
                                                   ^
In file included from /usr/include/c++/6/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/istream:38,
                 from /usr/include/c++/6/sstream:38,
                 from /usr/include/c++/6/complex:45,
                 from /usr/include/c++/6/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:52,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_pair.h:493:5: note: candidate: template<class _T1, class _T2> constexpr std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
     make_pair(_T1&& __x, _T2&& __y)
     ^~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:493:5: note:   template argument deduction/substitution failed:
prog.cpp:9:51: note:   candidate expects 2 arguments, 3 provided
    tuple2 = make_pair(1,"Studytonight","Loves You");
                                                   ^
prog.cpp:15:35: error: ‘pair2’ was not declared in this scope
    tie(id,first_name,last_name) = pair2;
                                   ^~~~~
stdout
Standard output is empty