Hi all,

I'm learning about the different ways of passing arguments for functions and everything (i think!) is clear in Koeings book (esp. p58). However, when I'm trying to pass an argument to modify it and keep its new value outside the function then it runs like I'm passing references. Can you please explain why the program below passes "final" as a refence even though I have put "bouble& fin"

Thank you
Spiros


Code:
#include<iomanip>
#include<ios>
#include<iostream>
#include<string>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::string;
using std::streamsize;

double grade(double mid, double& fin, double sum_count) {
        fin+=100;
        cout << endl
               << "Final grade (inside function) is: " << fin << endl;
        return 0.2*mid + 0.4*(fin-100) +0.4*sum_count;
}
int main()
{
        cout << "Enter your midterm and final exam grades: ";
        double midterm, final;
        cin >> midterm >> final;
        cout << "Enter your homework grades, followed by an CTRL-D to stop: ";

        int count=0; double sum=0; double x;
        while (cin >> x) {
                ++count;
                sum += x;
        }

        streamsize prec = cout.precision();
        cout << "Your total grade is " << setprecision(3)
                << grade(midterm, final, sum/count) << endl
                << "Also final grade (outside function) is: " << final
                << setprecision(prec) << endl;
        return 0;
}