04-24-2011, 05:54 PM
Dear sir, Salaam, Kindly check my this code. I have an error. Please point out my mistake. I want to send the reference of variable x to the function square. bye. --------------------------------------------------------------------- #include using namespace std; void square(double); int main() { double x; x = 123.456; cout << "\n" << "In main(), before calling square(), x = " << x; square(&x); //Passing address of the variable x cout << "\n" << " In main(), after calling square(), x = " << x; } void square(double *x) //read as: x is a pointer of type double { *x = *x * *x; //Notice that there is no space in *x }
