c++ variable als referenz in funktion code example
Example: referenz in einer funktion
#include
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);
}