Is it possible to return two variables with different types--e.g., string and integer, from a function in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it possible to return two variables with different types--e.g., string and integer, from a function in C++?

Can do this with Python; wondering about C++...

29th Jul 2016, 3:53 PM
SouthBay
SouthBay - avatar
4 Answers
+ 1
....or a std::pair (#include <utility>)
29th Jul 2016, 6:08 PM
Stefan
Stefan - avatar
0
No, but you could return a tuple.
29th Jul 2016, 4:01 PM
ddrodoric
0
A tuple with a string and integer in each slot. I see. But immutable.
29th Jul 2016, 5:11 PM
SouthBay
SouthBay - avatar
0
Makes a case for classes in C++
29th Jul 2016, 5:12 PM
SouthBay
SouthBay - avatar