Answers for "referenz in einer funktion"

1

referenz in einer funktion

#include <iostream>

void swap(int &wert1, int &wert2) {
    int tmp;
    tmp   = wert1;
    wert1 = wert2;
    wert2 = tmp;
}

int main() {
    int a = 7, b = 9;

    std::cout << "a: " << a << ", b: " << b << "\n";

    swap(a, b);

    std::cout << "a: " << a << ", b: " << b << "\n";
    return (0);
}
Posted by: Guest on November-09-2020

Browse Popular Code Answers by Language