樱花视频在线观看-西西人体大胆4444ww张筱雨-久久网免费视频-国产99页-91高清视频在线-日日干夜夜干-91社区视频-中文高清av-久久成人国产-亚洲日韩欧洲乱码av夜夜摸-97人人射-亚洲视频观看-理论片亚洲-亚洲精品99999-免费能看的黄色片-精人妻无码一区二区三区-奇米影视播放器

游戲產(chǎn)業(yè)研究網(wǎng)

C++編程題:設(shè)計一個時間類(Time),有年、月、日3個屬性

#include<iostream>

using namespace std;

class Date//定義日期類

{public:

Date(int,int,int);//聲明構(gòu)造函數(shù)

friend void display(Date &);//聲明友元函數(shù)顯示日期

private:

int year;//定義年

int month;//定義月

int day;//定義日

};

class Time//定義時間類

{public:

Time(int,int,int);//定義構(gòu)造函數(shù)

friend void display(Time &);//聲明友元函數(shù)顯示時間

private:

int hour;//定義時

int minute;//定義分

int second;//定義秒

};

Date::Date(int y,int m,int d)//定義構(gòu)造函數(shù)

{

year=y;

month=m;

day=d;

}

void display(Date &d)//定義友元函數(shù)顯示日期,使用Data的一個引用

{cout<<d.year<</<<d.month<</<<d.day<<endl;

}

Time::Time(int h,int m,int s)//定義構(gòu)造函數(shù)

{hour=h;

minute=m;

second=s;

}

void display(Time &t)//定義友元函數(shù)顯示時間,使用Time的一個引用

{cout<<t.hour<<:<<t.minute<<:<<t.second<<endl;

}

int main()

{Date d(2012,3,19);//帶參數(shù)聲明Data d

display(d);//顯示當(dāng)前的日期

Time t(21,34,45);//帶參數(shù)聲明Time t

display(t);//顯示當(dāng)前的時間

return 0;

}

#include<iostream>

using namespace std;

class Date

{public:

Date(int,int,int);

friend void display(Date &);

private:

int year;

int month;

int day;

};

class Time

{public:

Time(int,int,int);

friend void display(Time &);

private:

int hour;

int minute;

int second;

};

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

{

year=y;

month=m;

day=d;

}

void display(Date &d)

{cout<<d.year<</<<d.month<</<<d.day<<endl;

}

Time::Time(int h,int m,int s)

{hour=h;

minute=m;

second=s;

}

void display(Time &t)

{cout<<t.hour<<:<<t.minute<<:<<t.second<<endl;

}

int main()

{Date d(2012,3,19);

display(d);

Time t(21,34,45);

display(t);

return 0;

}

需要好幾個文件的....

class Date

{public:

Date(int,int,int);

friend void display(Date &);

private:

int year;

int month;

int day;

};

class Time

{public:

Time(int,int,int);

friend void display(Time &);

private:

int hour;

int minute;

int second;

};

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

{

year=y;

month=m;

day=d;

}

void display(Date &d)

{cout<<d.year<</<<d.month<</<<d.day<<endl;

}

Time::Time(int h,int m,int s)

{hour=h;

minute=m;

second=s;

}

void display(Time &t)

{cout<<t.hour<<:<<t.minute<<:<<t.second<<endl;

}

int main()

{Date d(2012,3,19);

display(d);

Time t(21,34,45);

display(t);

return 0;

}

阳山县| 肇州县| 华阴市| 洮南市| 芜湖县| 泽普县| 南江县| 沛县| 麻阳| 前郭尔| 孙吴县| 武宣县| 上蔡县| 阳信县| 叙永县| 黄平县| 卢龙县| 江山市| 吉木萨尔县| 桃园市| 九台市| 改则县| 中西区| 开平市| 高邑县| 凤山县| 桓台县| 子长县| 天镇县| 台中县| 尼玛县| 武功县| 东城区| 高要市| 延吉市| 神池县| 贵德县| 内黄县| 巴马| 奉化市| 仁化县|