diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2013-10-29 17:42:34 +0100 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2013-10-29 17:42:34 +0100 |
commit | 8f1093f0e00f9b1df7ce343a879303fd56a95d08 (patch) | |
tree | 6aaf0720c2093ba05cb81ba7f95b4e9808b3ecab /tests/exec/ref6.cpp | |
download | LPC-Projet-8f1093f0e00f9b1df7ce343a879303fd56a95d08.tar.gz LPC-Projet-8f1093f0e00f9b1df7ce343a879303fd56a95d08.zip |
First commit.
Diffstat (limited to 'tests/exec/ref6.cpp')
-rw-r--r-- | tests/exec/ref6.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/exec/ref6.cpp b/tests/exec/ref6.cpp new file mode 100644 index 0000000..3737786 --- /dev/null +++ b/tests/exec/ref6.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +int &f(int b, int &x, int &y) { + std::cout << "x = " << x << "\n"; + std::cout << "y = " << y << "\n"; + if (b) return x; else return y; +} + +int main() { + int x = 42; + int y = 43; + int &r = f(1, x, y); + // now r is an alias for x + r = 12; + std::cout << "x = " << x << "\n"; + std::cout << "y = " << y << "\n"; + f(0,x,y) = 13; + std::cout << "x = " << x << "\n"; + std::cout << "y = " << y << "\n"; +} |