Pointers
Is someone willing to explain how pointers work to me and why would I prefer to use them?
Here is an example code our professor gave to us.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
#include <string>
using namespace std;
int main (){
string *str;
string fName, lName; str = &fName;
*str = "Miller";
str = &lName;
*str = "Tommy";
cout << fName << " " << lName << endl;
return 0;
}
|
http://www.learncpp.com/cpp-tutorial/67-introduction-to-pointers/
Topic archived. No new replies allowed.