-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.cpp
More file actions
43 lines (37 loc) · 1.15 KB
/
Tuple.cpp
File metadata and controls
43 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
//#include <stringstream>
#include<tuple> // for tuple
#include <boost/tuple/tuple.hpp>
#include<string>
#include <sstream>
using namespace std;
using boost::tuple;
string Print(const tuple <string, int, float>& tuple_print)
{
std::string out_string;
std:stringstream buffer;
buffer << "Name: "<< get<0>(tuple_print) << " ,Age: " << get<1>(tuple_print) << " ,Height: " << get<2>(tuple_print) << endl;
out_string = buffer.str();
cout << out_string;
return out_string;
}
int main()
{
// Declaring tuple
tuple <string, int, float> geek;
// Assigning values to tuple using make_tuple()
geek = make_tuple("Mamadou Diallo", 31, 5.5);
// Printing initial tuple values using get()
cout << "The initial values of tuple are : ";
cout << get<0>(geek) << " " << get<1>(geek);
cout << " " << get<2>(geek) << endl;
// Use of get() to change values of tuple
//get<0>(geek) = "cde";
//get<2>(geek) = 20.5;
// Printing modified tuple values
cout << "The modified values of tuple are : ";
cout << get<0>(geek) << " " << get<1>(geek);
cout << " " << get<2>(geek) << endl;
cout << Print(geek);
return 0;
}