学生 老师 类

本文介绍了一个学生成绩管理系统的实现,包括学生信息录入、教师信息录入、成绩输入与展示等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



#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; 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值