Jan 10, 2016 at 10:15pm UTC
I cannot get passing by pointer to work in visual studio. Here is a simple example. Somebody tell me what I am doing wrong. I get the error "cannot convert argument 1 from 'int*' to 'int'
#include <iostream>
using namespace std;
void GetFraction(int numer, int denom);
int main()
{
int numer = 0, denom = 0;
GetFraction(&numer, &denom); // Pass by pointer
cout << numer << '/' << denom << endl;
return 0;
}
void GetFraction(int * numer, int * denom)
{
cout << "Enter numerator: ";
cin >> *numer;
cout << "Enter denominator: ";
cin >> *denom;
}
Jan 10, 2016 at 10:16pm UTC
Prototype void GetFraction(int numer, int denom);
doesn't match definition void GetFraction(int * numer, int * denom)
Jan 10, 2016 at 10:17pm UTC
Your function prototype doesnt match your function definition.
Jan 10, 2016 at 10:17pm UTC
....I am so stupid. Thanks