搜索
首页 电脑/网络 程序设计 VC++

用C++定义一个学生类

全部回答

2006-04-04

0 0
    //student。h #pragma once #include #include #include #include #include using namespace std; class Student { public: //构造函数 Student(void); //复制构造函数 Student(const Student &other); Student(int stu_id,string stu_name); //析构函数 ~Student(void); //返回id的值 int Getid() const; //设置id的值 bool Setid(int stu_id); //返回name的值 string Getname() const; //设置name的值 void Setname(string stu_name); //重载运算符== bool operator ==(const Student &other); bool operator ==(const string &stuname); bool operator ==(const int &stuid); //重载与算符!= template bool operator !=(const D &other) { return !(*this==other); }; //重载运算符= Student & operator =(const Student &other); //输出 void display(); private: // 学号 int id; // 姓名 string name; }; //设置 basic_ostream& operator& __os, const Student& __x) { basic_ostringstream __s; __s。
    flags(__os。
    flags()); __ bue(__ tloc()); __ ecision(__ ecision()); __s 99999){ cout<<setw(12)<<' '<<"学号范围应该在10000~99999之间!"<<endl; return false ; }//end of if else{ id=stu_id; return true; }//end of else } //Getname inline string Student::Getname() const { return name; } //Setname void Student::Setname(string stu_name) { name=stu_name; } //输出 void Student::display() { cout<<setw(10)<<' '<<"学号:"<<id<<endl; cout<<setw(10)<<' '<<"姓名:"<<name<<endl; }。

2006-04-03

394 0
晕,类中应该要有的信息是哪些啊 比如成员函数之类的,要不就是这个类中的操作啊 什么信息都没有,要怎么写呢?

2006-04-03

373 0
class student { }

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
VC++
硬件
电脑装机
程序设计
互联网
操作系统/系统故障
笔记本电脑
反病毒
百度
软件
程序设计
VC++
VB
数据库
C/C++
汇编语言
JAVA相关
C#/.NET
其他编程语言
VC++
VC++
举报
举报原因(必选):
取消确定举报