Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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