2015.3.25考了语文数学的学生

#include<iostream>
using namespace std;
#include"stu.h"
int main()
{
    Stu s1,s2;
    s1.setStudent("lin daiyu",98,96);
    s2.setStudent("jia baoyu",90,88);
    s1.show();
    s2.show();
    s1.setName("xue baochai");
    s1.show();
    cout<<"s1.Name:"<<s1.getName()<<endl;
    cout<<"s2.average:"<<s1.average()<<endl;
    return 0;
}

#ifndef STU_H_INCLUDED
#define STU_H_INCLUDED
class Stu
{
private:
    string name;
    float chinese;
    float math;
public:
    void setStudent(string,float,float);
    void show();
    void setName(string a)
    {
        string name;
    };
    string getName()
    {
        return name;
    };
    float average();
    float sum();

};

#endif // STU_H_INCLUDED

#include<iostream>
using namespace std;
#include"stu.h"
void Stu::setStudent(string a, float x,float y)
{
    name=a;
    chinese=x;
    math=y;
}
void Stu::show()
{
    cout<<"Name:"<<name<<'\n'<<"Score:"<<chinese<<" "<<math<<endl;
    cout<<"Average"<<Stu::average()<<"Sum"<<Stu::sum()<<endl;

}
float Stu::average()
{
    float a;
    a=chinese+math;
    a/=2.0;
    return a;
}
float Stu::sum()
{
    float b;
    b=chinese+math;
    return b;
}


 

想不到现在了还能因为把main写成mian而搞了半天都弄不出来。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值