标题:改了很久,还是感觉怪怪的
取消只看楼主
yxieguodong
Rank: 1
来 自:广东湛江
等 级:新手上路
帖 子:17
专家分:8
注 册:2011-4-17
结帖率:66.67%
已结贴  问题点数:20 回复次数:0 
改了很久,还是感觉怪怪的
#include <iostream>
using namespace std;

class DayOfYear
{
public:
    friend bool equal(DayOfYear date1,DayOfYear date2);    //友元
    DayOfYear(int the_month,int the_day);
    DayOfYear();
    void input();
    void output();
    int get_month();
    int get_day();
//private:
    void check_date();
    int month;
    int day;
};

int main ()
{
    DayOfYear today,bach_birthday(3,21);

    cout<<"输入今天日期:";
    today.input();
    cout<<"今天是";
    today.output();

    cout<<"xxx的生日是";
    bach_birthday.output();

    if(equal(today,bach_birthday))
        cout<<"happy!";
    else
        cout<<"unhappy!";

    return 0;
}

bool equal(DayOfYear date1,DayOfYear date2)
{
    return(date1.month == date2.month && date1.day ==date2.day);
}
DayOfYear::DayOfYear(int the_month,int the_day):month(the_month),day(the_day)
{
    //无动作
}

int DayOfYear::get_month()
{
    return month;
}
int DayOfYear::get_day()
{
    return day;
}
//使用iostream
void DayOfYear::input()
{
    cout<<"输入月份:";
    cin>>month;
    cout<<"输入日期:";
    cin>>day;
}
void DayOfYear::output()
{
    cout<<"月:"<<month<<",日:"<<day<<endl;
}
搜索更多相关主题的帖子: private 今天日期 
2011-06-16 01:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-343012-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.122540 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved