Overloaded functions

My compiler keeps telling me that "None of the 3 overloads could convert all the argument types"
And I'm pretty sure they can, and i have no idea why it keeps telling me that.

 
typdedef vector<double> container;

1
2
3
4
5
6
struct Student_info
{
	string name;
	double midterm, final;
	container homework;
};

1
2
3
4
//prototypes
double	grade(double midterm, double final, double homework);
double	grade(double midterm, double final, container& hw);
double	grade(const Student_info& s);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
double grade(double midterm, double final, double homework)
{
	return 0.2 * midterm + 0.4 * final + 0.4 * homework;
}
double grade(double midterm, double final, container& hw)
{
	if(hw.size() == 0)
		throw domain_error("student has done no homework");
	return grade(midterm, final, median(hw));
}
double grade(const Student_info& s)
{
	return grade(s.midterm, s.final, s.homework); //this is where the compiler is telling me there's an issue
}


Compiler output:

error C2665: 'grade' : none of the 3 overloads could convert all argument types
: could be 'double grade(double,double,double)'
: or       'double grade(double,double,container &)'
while trying to match the argument list '(const double, const double, const container)'


So yeah, I'm pretty sure there's an overload there to take that call..
Anyone see anything i missed?
Last edited on
Change double grade(double midterm, double final, container& hw) to double grade(double midterm, double final, const container& hw) // Note const and it will match
Hah!
I'm an idiot. Guess I just needed a fresh set of eyes. Been at this for hours.
Thanks a bunch coder777. (:
Topic archived. No new replies allowed.