Can we add more than 2 entries for the datatype pair<>

can we make pair<string,int,int,float> x, and access the elements like x.first, x.second, x.third and so on?

hello @namanmittal0007

we cannot do that , but we can do nesting.

for example -
pair< pair < string,int> , pair< int, float> > x;

to access string -> x.first.first
to access float-> x.second.second
to access left int -> x.first.second
to access right int-> x.second.first

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.