Created
September 28, 2016 15:21
-
-
Save dmcleish91/93f3a33c819c0d3a1fc49e1b76c7a10f to your computer and use it in GitHub Desktop.
Revisions
-
TheStygianSun created this gist
Sep 28, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #include <iostream> #include <string> using namespace std; void change(string* change_first, string* change_last) // in this function we created a pointer { *change_first = "Master"; // this allows us to change the variable because we know its memory address *change_last = "piece"; } int main() { string first = "first"; // declaring some normal variables string last = "last"; cout << first << last << "\n"; change(&first, &last); // we use & to make the pointer reference the variable cout << first << last << "\n"; system("pause"); }