Last active
June 26, 2021 18:24
-
-
Save JoshCheek/2fca3ef9d2467e8b1c7868ec4711dfd6 to your computer and use it in GitHub Desktop.
Pretty sure C++ refs are just obfuscating syntax around pointers
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
// code for the screenshot in this tweet https://twitter.com/josh_cheek/status/1408853467150663680 | |
#include "stdio.h" | |
void inc1(int& n) { ++ n; } | |
void inc2(int* n) { ++*n; } | |
int main(int argc, char** argv) { | |
int a = 0, b=0; | |
printf("a=%d, b=%d\n", a, b); | |
inc1(a); inc2(&b); | |
printf("a=%d, b=%d\n", a, b); | |
inc1(a); inc2(&b); | |
printf("a=%d, b=%d\n", a, b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment