Reference

I am trying to get reference working with my program but am having difficulties with it giving out the right number. I am just working on the void GetArea(double radius, double& area) right now. The program works all except for that void referencing. How do I go about getting it to reference area from my main()?
Last edited on
std::cout << "Area using reference semeantics: " << GetArea(area) << endl;

There are 2 things wrong with this line.

1) The reference GetArea function does not return anything (it has a void return type), so you can't give it to cout like that.

2) The reference GetArea function takes 2 parameters: the radius (input), and the area (output). You're only giving it one parameter.

See this page for more:

http://cplusplus.com/doc/tutorial/functions2/
By passing area as a parameter.
Please use code tags, the code is completely unreadable without them.
Topic archived. No new replies allowed.