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
Get step-by-step solutions from verified subject matter experts
