程序如下,average__analysis無法定義_
#ifndef GUARD_average_grade
#define GUARD_average_grade
#include"grade.h"
#include"Student_info.h"
#include"average_analysis.h"
#include
double average_grade(const Student_info&s)
{
try{
return average_analysis(s); //這個位置average_analysis(s)無法被定義標識符
}catch(domain_error){
return grade(s.midterm,s.final,0);
}
}
#endif
定義average_analysis函數的程序如下:
#ifndef GURAD_average_analysis
#define GURAD_average_analysis
#include
#include
#include"Student_info.h"
#include"grade輔助函數,捕抓錯誤.h"
#include"average_grade.h"
double average(const vector&v)
{
return accumulate(v.begin(),v.end(),0.0)/v.size();
}
double average_analysis(const Student_info&s)
{
return grade(s.midterm,s.final,average(s.homeworks));
}
double average_analysis(const vector&student)
{
vector grades;
transform(student.begin(),student.end(),back_inserter(grades),average_grade);
return median(grades);
}
#endif
我從來沒用過這樣的文件名,不曉得編譯器支持不,你最好能將所有的編譯結果貼出來。