Use the program, Passing-by-value, on the bottom of pp. 248–249 and the program,
Passing-by-reference, on pp. 255–256 as a starting point for this assignment. Write a similar program, but change the code to pass two variables to the function call rather than one.
that's my assignment and i have tried to come up with something but i am totally lost.. here is what i have so far... I think im supose to use a const im not sure though...
#include <iostream>
using std::cout;
using std::endl;
int accelerate(int* speed);
int gear(int* gear);
int main (void)
{
int speed = 20;
int gear = 3;
cout << endl
<< "Current speed: " << speed << endl
<< "Current gear: " << gear << endl;
int* pspeed = &speed;
int* pgear = &gear;
cout << endl
<< "Memory address passed for speed variable: " << pspeed << endl
<< "Memory address passed for gear: " << pgear << endl;
int accelResult = accelerate (pspeed);
int changedGear = gear (pgear);
cout << endl
<< "Changed gears to: " << changedGear << endl
<< "Speed accelerated: " << accelResult << endl;
system("PAUSE");
return 0;
}
int accelerate(int* speed)
{
*speed += 25;
return *speed;
}
int gear(int* gear)
{
*gear += 1;
return *gear;
}
Thank you for your time.