Skip to content

Instantly share code, notes, and snippets.

@ubaidh
Last active July 30, 2020 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubaidh/c1824cee899996c580c1c2a8fbcab44b to your computer and use it in GitHub Desktop.
Save ubaidh/c1824cee899996c580c1c2a8fbcab44b to your computer and use it in GitHub Desktop.
#include<tuple>
#include<string>
#include<iostream>
int main() {
std::tuple<int, std::string, char> t(3, "hello world", 'a');
std::cout << std::get<0>(t) << std::endl;
std::cout << std::get<1>(t) << std::endl;
std::cout << std::get<2>(t) << std::endl;
std::cout <<" \n";
std::tuple<int, std::string, char> t2; //default constructor
t2 = std::tuple<int, std::string, char>(34, "ko ok", 'w');
std::string& s = std::get<1>(t2);
s = "pound";
std::cout << std::get<0>(t2) << std::endl;
std::cout << std::get<1>(t2) << std::endl;
std::cout << std::get<2>(t2) << std::endl;
std::cout << " \n";
std::tuple<int, std::string, char> t3;
t3 = std::make_tuple(45, "dfdf", 'd');
std::get<1>(t3) = "hello";
std::cout << std::get<0>(t3) << std::endl;
std::cout << std::get<1>(t3) << std::endl;
std::cout << std::get<2>(t3) << std::endl;
std::cout << " \n";
std::cin.get();
}
//gcc -std=c++11 -o tuple.exe tuple.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment