Skip to content

Instantly share code, notes, and snippets.

@DalyaG
Last active May 18, 2020 17:24
Show Gist options
  • Save DalyaG/097b2483b1889202a6ee3c63a7c11661 to your computer and use it in GitHub Desktop.
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.
#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