Last active
May 18, 2020 17:24
-
-
Save DalyaG/097b2483b1889202a6ee3c63a7c11661 to your computer and use it in GitHub Desktop.
Pointers and references in C++: what happens with no pointers and no references.
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 <iostream> | |
using namespace std; | |
int main() { | |
int a = 1; | |
int b = a; | |
cout << "b gets the value that is inside a\n"; | |
cout << "a=" << a << ", b=" << b << endl; | |
// prints: a=1, b=1 | |
a = 3; | |
cout << "changing a does not change anything else\n"; | |
cout << "a=" << a << ", b=" << b << endl; | |
// prints: a=3, b=1 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment