一道定义学生类的C++简单题 来帮我下 ~~

来源:百度知道 编辑:UC知道 时间:2024/05/18 10:35:10
定义一个学生类,其中由个数据成员 有学号.姓名.年龄 以及若干成员函数. 同时编写主函数使用这个类.实现对学生数据的赋值和输出
要求 1. 使用成员函数实现对输出的输入 输出
2.使用构造函数和析够函数实现对数据的输入 输出

//这是我写过的一个类,老师和学生都有,学生类里有你要的所有数据成员,我稍加修改了一下,你看看合用就拿去用.要完成你的功能实在太容易,我就不帮你写完整了

#include <iostream>
#include<cstring>
using namespace std;
class teacher;
class student
{
private:
int num; //学号
char *name;//姓名
int age; //年龄
float score; //成绩
char *tname; //指导教师
static float total; //总分
static int count; //累加计数器
public:
student(int number=1000,int ag=18,float sc=100,char *sname,char *tn="wang")
{
num = number;
age = ag;
score = sc;
name=new char[strlen(sname)+1];
strcpy(name,sname);
tname=new char[strlen(tn)+1];
strcpy(tname,tn);
}
~student(){delete[] tname;delete[] name;}
char *showt(){return tname;}
int getnum(){return num;}
int getage(){return age;}
float getscore(){return score;}
float gettotal(){return total;}
int getcount(){return count;}
void addcount(){count++;}
void