Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,939 questions

51,876 answers

573 users

How to change the values of tuple in C++

1 Answer

0 votes
#include <iostream>
#include <tuple> 
  
using namespace std; 
  
int main()
{
    tuple <char, int, float, string> t; 
  
    t = make_tuple('z', 89, 3.14, "c++"); 
    
    cout << get<0>(t) << endl;
    cout << get<1>(t) << endl;
    cout << get<2>(t) << endl;    
    cout << get<3>(t) << endl << endl;
     
    get<0>(t) = 'a'; 
    get<1>(t) = 987;     
    get<2>(t) = 1.89;  
    get<3>(t) = "cpp"; 
     
    cout << get<0>(t) << endl;
    cout << get<1>(t) << endl;
    cout << get<2>(t) << endl;    
    cout << get<3>(t) << endl;
 
    return 0;
}
  
  
  
/*
run:
  
z
89
3.14
c++
 
a
987
1.89
cpp
  
*/

 



answered Feb 8, 2020 by avibootz
edited Feb 8, 2020 by avibootz

Related questions

2 answers 243 views
2 answers 183 views
183 views asked Feb 7, 2020 by avibootz
1 answer 75 views
1 answer 132 views
132 views asked Oct 29, 2018 by avibootz
...