第四章学生类

#include<iostream>
#include<string>
using namespace std;
class student;
class teacher{
public:
	teacher(string i,string j)
	{
		name=i;
		number=j;
	}
	void show(student&);
	void input(student&);
private:
	string name;
	string number;
	
};
class student{
public:
	student(string a,string b)
	{
		Name=a;
		ID=b;
	}
	friend teacher;
private:
	string Name;
	string ID;
	double English;
	double math;
};
void teacher::input(student& s)
{
	cout<<"请输入"<<s.Name<<"学生的英语成绩:";
	cin>>s.English;
	cout<<"请输入"<<s.Name<<"学生的数学成绩:";
	cin>>s.math;
}
void teacher::show(student& s)
{
	cout<<"学生:"<<s.Name<<endl;
	cout<<"学号:"<<s.ID<<endl;
	cout<<"英语成绩:"<<s.English<<endl;
	cout<<"数学成绩:"<<s.math<<endl;
}
int main()
{
	student stu1("chenhuaqing","201411671202");
	student stu2("doubishi","201411671221");
	teacher tea1("mingge","0000");
	tea1.input(stu1);
	tea1.input(stu2);
	tea1.show(stu1);
	tea1.show(stu2);
	system("pause");


}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值