Google News
logo
CPP - Quiz(MCQ)
What are the tuples in C++?
A)
Objects that can hold a single element of complex type
B)
Objects that can hold more than one element of the same types
C)
Objects that can hold a single element of fundamental type
D)
Objects that can hold more than one element of different types

Correct Answer :   Objects that can hold more than one element of different types


Explanation :

A tuple is an object that can hold a number of elements. The elements can be of different data types. The elements of tuples are initialized as arguments in order in which they will be accessed.
 
Operations on tuple :
 
1. get() : get() is used to access the tuple values and modify them, it accepts the index and tuple name as arguments to access a particular tuple element.
 
2. make_tuple() : make_tuple() is used to assign tuple with values. The values passed should be in order with the values declared in tuple.
 
3. tuple_size : It returns the number of elements present in the tuple.
 
4. swap() : The swap(), swaps the elements of the two different tuples.
 
5. tie() : The work of tie() is to unpack the tuple values into separate variables. There are two variants of tie(), with and without “ignore” , the “ignore” ignores a particular tuple element and stops it from getting unpacked.
 
6. tuple_cat() : This function concatenates two tuples and returns a new tuple.

Advertisement