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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started