Question: using c++ void swapthroughpointer ( int * left, int * right) { int temp = *left; *left= *rhs; *right= temp; } void swapthroughref( int &

using c++

void swapthroughpointer(int* left, int* right) { int temp = *left; *left= *rhs; *right= temp; } void swapthroughref(int& left, int& right) { int temp = left; left= right; right= temp; }
int main() { int a = 2; int b = 3; swapthroughRef(a,b); swapthroughpointer(&a,&b); }

what are the variables that are put into the stack and heap before the first line of swapthroughRef(a,b) is executed? how about swapthroughpointer(&a,&b)?

what are the variables that are put into the stack and heap after swapthroughRef(a,b); is executed? how about swapthroughpointer(&a,&b)?

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!