I have this code that was done using pass by reference but now all the pass by references need to be changed to pass by pointer. Im not sure how to do this going back and forth between the functions. Here's what I have so far.
#include <iostream>
#include <cmath>
using std::cout;
using std::endl;
int Fun1 ( int a, int b );
void Fun2 ( int * A, int b );
void Fun3 ( int * c, int * d );
void PrintOutput( int a, int b );
int main ( )
{
int a = 2;
int b = 10;
int *A = & a;
PrintOutput ( a, b );
a = Fun1 ( a, b );
cout << a << "\t" << b << endl;
Fun2 ( A, b );
PrintOutput ( a, b );
return 0;
}
// PrintOutput
void PrintOutput ( int a, int b )
{
cout << a << "\t" << b << endl;
}
// Fun1
int Fun1 ( int a, int b )
{
int c;
c = a + b;
a++;
--b;
cout << a << "\t" << b << "\t" << c << endl;
return c;
}
// Fun2
void Fun2 ( int * A, int b )
{
*A += 5;
double temp = pow(static_cast<double>(*A), 2);
b = static_cast<int>( temp );
PrintOutput ( a, b );
Fun3 ( a, b );
PrintOutput ( a, b );
}
// Fun3
void Fun3 ( int * c, int * d )
{
*c = 25;
*d = 10;
PrintOutput ( c, d );
}