学生 老师 类
2015-04-29 21:53
211 查看
#include<iostream>
#include<string>
using namespace std;
class Student
{ friend class teacher;
string name;
int id;
int english;
int math;
public:
Student(string n,int i)
{ name=n;
id=i;
english=0;
math=0;
}
void show_score()
{cout<<name<<"::"<<"id:"<<id<<"english= "<<english<<" math= "<<math<<endl;
}
};
class teacher
{ string name;
string num;
public:
teacher(string n1,string n2)
{
name=n1;
num=n2;
}
void show_teacher_data()
{cout<<"name:"<<name<<'\n'<<"num:"<<num<<endl;
}
void score_keying(Student &s)
{ int e,m;
cout<<"please input score of "<<s.name<<endl;
cout<<"englsih:";
cin>>e;
cout<<"math:";
cin>>m;
s.english=e;
s.math=m;
}
};
int main()
{
Student st("lipengfei",14213);
teacher mingge("mingge","000000");
mingge.show_teacher_data();
mingge.score_keying(st);
st.show_score();
system("pause");
return 0;
}
#include<iostream>
#include<string>
using namespace std;
class Student
{ friend class teacher;
string name;
int id;
int english;
int math;
public:
Student(string n,int i)
{ name=n;
id=i;
english=0;
math=0;
}
void show_score()
{cout<<name<<"::"<<"id:"<<id<<"english= "<<english<<" math= "<<math<<endl;
}
};
class teacher
{ string name;
string num;
public:
teacher(string n1,string n2)
{
name=n1;
num=n2;
}
void show_teacher_data()
{cout<<"name:"<<name<<'\n'<<"num:"<<num<<endl;
}
void score_keying(Student &s)
{ int e,m;
cout<<"please input score of "<<s.name<<endl;
cout<<"englsih:";
cin>>e;
cout<<"math:";
cin>>m;
s.english=e;
s.math=m;
}
};
int main()
{
Student st("lipengfei",14213);
teacher mingge("mingge","000000");
mingge.show_teacher_data();
mingge.score_keying(st);
st.show_score();
system("pause");
return 0;
}
相关文章推荐
- 高3老师给大一学生的一封信
- 第48篇一对多实现(五)老师端动态加载学生头像及PHP array_map
- 教育的失败:学生打老师
- 成都传智播客,学生老师共同举杯庆祝初战高胜!
- 1.显示的字段要有老师name, age 每个老师所带的学生人数,2 只列出老师age为40以下学生age为12以上的记录
- 学谈“上课学生睡觉,是老师的错”
- 分页查询+万能---数据库例题的学生老师信息表为前提
- 答学生:靠点名留学生的老师就跟靠怀孕留男人的小三一样
- 高三老师给大一学生的一封信
- 根据老师编号,统计其所授课程的平均成绩及学生人数。
- 60万英语老师,在辛勤工作着,培养着一批又一批聋哑学生······
- 作IT学生不容易,当IT老师也很难(续)——软件教育随想(3)
- 学生给老师的一道思考题
- 知道老师,得到学生的集合
- 哈佛老师经常给学生的告诫
- 哈佛老师经常给学生这样的告诫
- 现代软件工程系列 学生和老师都不容易
- 大学生应该读什么书——一位年轻老师给他的年轻学生的一封回信
- 老师布置的C++实践作业:C++编写的学生系统
- 面向对象_老师学生案例加入抽烟功能分析及代码实现