In C++ programming, an asterisk is used to declare a pointer. Pointers allow you to refer directly to values in memory, and allow you to modify elements that would otherwise only be copied.
You could change an argument to use a reference, but every time you wanted to use that address, you would need to add ampersands (&) everywhere. Instead, the string variable can be changed using a pointer.
Creating Pointers
Again, a pointer points to a specific value stored at a specific address in a computer's memory. You can think of it as a variable for another variable's address.
To declare a pointer, use an asterisk (*). Below where input is declared, type:
string* pointer;
To initialize a pointer, use an ampersand (&), which is an address-of operator. Below where the pointer is declared, type:
pointer = &input;
That sets your variable, called pointer, to the address of input.
Still stuck? Get started with an Online Private Lesson in C++, where your child can learn more about the wide world of coding and development with the help and expertise of a dedicated, experienced instructor.