/* ********************************************* The Fix for the aliasing problem in C++ Output: 3 2 ********************************************** */ #include < iostream.h > void SomeFunction(int& InputVar1, int&InputVar2) { InputVar1 = InputVar2 + 1; //Uses both local Variables cout << InputVar1 << endl; cout << InputVar2 << endl; } void main() { int L_Var1 = 2; //use a Local Variable instead int L_Var2 = 2; //Another Local Variable /*calls SomeFunction with the global Variable as a parameter */ SomeFunction(L_Var1, L_Var2); }
These pages were edited for style and content by
Allan Caine, Laura Drever, Gorana Jankovic, Megan King, and Marie Lewis.
The original authors of these pages were Graeme Humphries, Chantal Laplante, Chris Mills,
and Melvin Lenz.
Last Modified: Wednesday, June 7th 23:45:30
Copyright 2000 Department of Computer Science, University of
Regina.