Overloading_grade_program_accelerated_c++_book

  c++, overloading

So I am doing exercices in accelerated c++ book. But when i try to rework the code from book. Visual studio keep saying that is more than one instance of overloaded function "grade" matches the argument list. But I can not see where is the overloading problem. Can someone please help me with this ?

grade.h

#ifndef GUARD_grade_h
#define GUARD_grade_h

#include <vector>
#include "student_info.h"

double grade(double, double, double);
double grade(double, double, const std::vector<double>&);
double grade(const Student_info &);

#endif // !GUARD_grade_h

grade.cpp

#include <vector>
#include <stdexcept>
#include "median.h"
#include "student_info.h"
#include "grade.h"

using std::domain_error; using std::vector;

double grade(double midterm, double final, double homeworks) 
{
    return 0.2 * midterm + 0.4 * final + 0.4 * homeworks;
}

double grade(double midterm, double final, const vector<double> hm)
{
    if (hm.size() == 0)
        throw domain_error("student has done no homework");
    return grade(midterm, final, median(hm));
}

double grade(const Student_info& s)
{
    return grade(s.midterm, s.final, s.homework); // this grade is saying that is more then one
    //instance of overloaded function "grade"
}

Source: Windows Questions C++

LEAVE A COMMENT