Question: C++ help with pointers please!!! I'm doing a bit of practice and I want some help in understanding on what every line of code does

C++ help with pointers please!!!

I'm doing a bit of practice and I want some help in understanding on what every line of code does and what some line of code can't work. Give me a thorough understanding on what's what and how some variables interact with each other depending on the pointers or double pointers. Thank you!!!

Practice code:

int var = 789; cout << var; cout << endl;

//pointer for var int *ptr2; //cout << ptr2 << endl; // cout << *ptr2 << endl; cout << &ptr2 << endl; cout << endl;

//double pointer for ptr2 int **ptr1; //cout << ptr1 << endl; //cout << *ptr1 << endl; cout << &ptr1 << endl;

//storing address of var in ptr2 ptr2 = &var; cout << var << endl; cout << &var << endl; //cout << *var << endl; cout << endl;

//storing address of ptr2 in ptr1 ptr1 = &ptr2; cout << ptr1 << endl; cout << *ptr1 << endl; cout << &ptr1 << endl; cout << ptr2 << endl; cout << *ptr2 << endl; cout << &ptr2 << endl; cout << endl; system("pause");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!