C语言邮箱名字用什么存储,用c++定义一个描述学生通讯录的类数据成员包括姓名学校电话号码和邮箱...

满意答案

00e27ab806e4881f8254fe7ae8741834.png

egmwhy

2013.12.31

00e27ab806e4881f8254fe7ae8741834.png

采纳率:54%    等级:12

已帮助:8300人

很简单 的

给个差不多的你看看就知道了

#include

#include

#include

using namespace std;

class Student

{ int ID;

string name;

double score;

Date birth;

public:

void Set(int ID1,string name1,double score1);

int GetID()const { return ID; }

string GetName()const { return name; }

double GetScore()const { return score; }

Date GetBirth()const { return birth; }

void SetID(int ID1) { ID=ID1; }

void SetName(string name1) { name=name1; }

void SetScore(double score1){ score=score1; }

void SetBirth(Date birth1) { birth=birth1; }

void Output()const;

void Output(ofstream &fout)const;

void Input(istream &i);

};

void Date::Set(int y,int m,int d)

{ year=y; month=m; day=d; }

void Date::Set(const string &s)

{ year=atoi(s.substr(0,4).c_str() ); // 转换得到C串

month=atoi(s.substr(5,2).c_str());

day=atoi(s.substr(8,2).c_str());

}

void Date::Output()const

{ cout <

void Date::Input(istream &i)

{ i>>year>>month>>day; }

void Date::Output(ofstream &fout)const

{ fout <

bool Date::IsLeapYear()

{ return (year%4==0 && year%100!=0) || (year%400==0); }

void Date::Add(int days)

{ year=year+days /365;

month=(month + (days %365)%30)%12;

day=(day+ days%30) % 30;

}

int Date::Sub(Date &d)

{

return (year-d.year)*365+(month-d.month)*30+day-d.day;

}

Date Date::Sub(int days)

{ Date d;

d.Set(year,month,day-days);

return d;

}

void main()

{ Student sts[2]; // Student *sts=new Student[2];

Date d;

ofstream fout; fout.open("1.txt");

sts[0].Set(1,"aaa",99); d.Set(2007,1,1); sts[0].SetBirth(d);

sts[0].Output(fout);

sts[1].Set(2,"BBB",89); d.Set(2007,1,3); sts[1].SetBirth(d);

sts[1].Output(fout);

fout.close();

// delete []sts;

}

00分享举报

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值