Question: Resolving Pointers in C++ Given the image above, fill in the code belo
ID: 3844287 • Letter: Q
Question
Question: Resolving Pointers in C++
Given the image above, fill in the code below with the correct symbols.
int_ a = ________;
int_ b = __ a;
int [ Select ] ["", "*", "&"] a = [ Select ] ["3", "new int(3)"] ;
int [ Select ] ["", "*", "&"] b = [ Select ] ["", "*", "&"] a;
Explain why your answer is correct. I am not sure which choice would be correct. If * is required or & is selected, please explain why those are the correct symbols.
b 3 a 3Explanation / Answer
int main () { int a = 3, b = 3; int * p1, * p2; p1 = &a; // p1 = address of a p2 = &b; // p2 = address of b *p1 = 10; // value pointed to by p1 = 10 *p2 = *p1; // value pointed to by p2 = value pointed to by p1 p1 = p2; // p1 = p2 (value of pointer is copied) *p1 = 20; // value pointed to by p1 = 20 coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.