Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ return multiple values

#include <tuple>

std::tuple<int, int> divide(int dividend, int divisor) {
    return  std::make_tuple(dividend / divisor, dividend % divisor);
}

#include <iostream>

int main() {
    using namespace std;

    int quotient, remainder;

    tie(quotient, remainder) = divide(14, 3);

    cout << quotient << ',' << remainder << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ function as param 
Cpp :: arguments to a class instance c++ 
Cpp :: slice std::array cpp 
Cpp :: c++ vector fill 
Cpp :: how print fload wiht 2 decimal in c++ 
Cpp :: print all elements of vector c++ 
Cpp :: SetUnhandledExceptionFilter 
Cpp :: const char to string 
Cpp :: max heap in c++ 
Cpp :: all data types in c++ 
Cpp :: c++ segmented sieve 
Cpp :: vector search by element 
Cpp :: c++ inline in .cpp and not in header 
Cpp :: remove element from array c++ 
Cpp :: ubuntu dotnet core install 
Cpp :: C++ break and continue 
Cpp :: reading file c++ 
Cpp :: stl sort in c++ 
Cpp :: cout hex c++ 
Cpp :: time of a loop in c++ 
Cpp :: string to upper c++ 
Cpp :: convert letters to uppercase in c++ 
Cpp :: how to reverse a string in c++ 
Cpp :: c++ insert into map 
Cpp :: json::iterator c++ 
Cpp :: remove element from vector 
Cpp :: iterate through list c++ 
Cpp :: c++ hash combine 
Cpp :: how to cout in c++ 
Cpp :: c++ switch statement 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =