返回信息流程序报错error LNK2001,网上也查了相关内容,还是不太理解,求大神帮忙看一下
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class Student_info
{
private:
double midterm, final;
string n;
public:
Student_info();
Student_info(istream& in);
string name() const
{
return n;
};
double MT()
{
return midterm;
};
double FN()
{
return final;
};
istream& read(istream& in);
//double grade() const;
string PingJi(double midterm, double final) const;
};
istream& Student_info::read(istream& in)
{
in>>n>>midterm>>final;
in.clear();
return in;
}
double GradeCount(double midterm, double final) //50%期中+50%期末
{
return 0.5 * midterm + 0.5 * final;
}
string Student_info::PingJi(double midterm, double final) const
{
double Grade = GradeCount(midterm, final);
string pingjia;
if (Grade >= 60) //如果均分大于60,则给pass
return pingjia = "pass";
else //如果均分大于60,则给pass
return pingjia = "fail";
}
bool compare (const Student_info& x, const Student_info& y)
{
return x.name() > y.name();
}
template <class T>
T Comp (T a, T b)
{
if (a > b)
return a;
else
return b;
}
int main()
{
vector <Student_info> students;
Student_info record;
string::size_type maxlen = 0;
while (record.read(cin)) //循环输入
{
maxlen = Comp(maxlen, record.name().size()); //VC6.0不支持max和min函数
students.push_back(record);
}
sort(students.begin(), students.end(), compare);
for (vector<Student_info>::size_type i = 0; i != students.size(); i++)
{
cout<<students[i].name()<<string(maxlen + 1 - students[i].name().size(), ' '); //n不允许访问,使用name()
double mid = students[i].MT();
double fin = students[i].FN();
string final_PJ = students[i].PingJi(mid,fin);
cout<<final_PJ<<endl;
}
return 0;
}
这是一条镜像帖。来源:北邮人论坛 / cpp / #83663同步于 2014/10/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
error LNK2001 表示不太理解
Binghuo2
2014/10/25镜像同步1 回复
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复