新微赢技术网

标题: [开源][求助]仅一处错误!成员函数为什么不能调用string类的成员变量。。。 ... [打印本页]

作者: 乄獨萊◇獨徍    时间: 2009-11-6 01:51
标题: [开源][求助]仅一处错误!成员函数为什么不能调用string类的成员变量。。。 ...
#include <iostream.h>
#include <string>
using namespace std;

class student
{
private:
string no;
string name;
float deg1;
float deg2;
float deg3;
static float sum1,sum2,sum3;
static int num;
public:

student(string no,string name,float deg1,float deg2,float deg3)
{
this->no = no;
this->name = name;
this->deg1 = deg1;
this->deg2 = deg2;
this->deg3 = deg3;
sum1+=this->deg1;
sum2+=this->deg2;
sum3+=this->deg3;
num+=1;
}

float avg1()
{
return sum1/num;
}
float avg2()
{
return sum2/num;

}
float avg3()
{

return sum3/num;

}
void disp()
{
cout<<name<<endl;-------------------------------------------->>???这处不明白呀?
cout<<"语文总成绩:"<<sum1<<endl;
cout<<"数学总成绩:"<<sum2<<endl;
cout<<"英语总成绩:"<<sum3<<endl;

}
};
float student::sum1 = 0;
float student::sum2 = 0;




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2