$ g++ reference.cpp && ./a.out
num1: 0, num2: 0
num1: 1, num2: 1
num1: 2, num2: 2
Last active
August 14, 2016 05:41
-
-
Save JoshCheek/7f13eadc46a4aee0d66688dd424e3d85 to your computer and use it in GitHub Desktop.
C++'s reference type antagonizes ontological clarity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int num1 = 0; | |
int& num2 = num1; | |
printf("num1: %d, num2: %d\n", num1, num2); | |
num1 = 1; | |
printf("num1: %d, num2: %d\n", num1, num2); | |
num2 = 2; | |
printf("num1: %d, num2: %d\n", num1, num2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment