| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 397 人关注过本帖
标题:改了很久,还是感觉怪怪的
只看楼主 加入收藏
yxieguodong
Rank: 1
来 自:广东湛江
等 级:新手上路
帖 子:17
专家分:8
注 册:2011-4-17
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:5 
改了很久,还是感觉怪怪的
#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
Toomj
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:257
专家分:1826
注 册:2011-5-17
收藏
得分:5 
少个无参构造方法
DayOfYear(){}
2011-06-21 15:45
lianjiecuowu
Rank: 3Rank: 3
来 自:安徽
等 级:论坛游侠
帖 子:152
专家分:107
注 册:2011-5-20
收藏
得分:5 
#include <iostream>
using namespace std;

class DayOfYear
{
public:
    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:
    int month;
    int day;
};
bool DayOfYear:: equal(DayOfYear date1,DayOfYear date2)
{
    if(date1.month=date2.month&&date1.day==date2.day)
    return true;
    else return false;
   
}
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;
}

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

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

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

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

    return 0;
}

Sharp your mind!
2011-06-22 11:25
lianjiecuowu
Rank: 3Rank: 3
来 自:安徽
等 级:论坛游侠
帖 子:152
专家分:107
注 册:2011-5-20
收藏
得分:10 
以下是引用yxieguodong在2011-6-16 01:50:20的发言:

#include <iostream>
using namespace std;

class DayOfYear
{
public:
    friend bool equal(DayOfYear date1,DayOfYear date2);    //友元                 
    DayOfYear(int the_month,int the_day);
    DayOfYear();                          //是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)                              //bool类型返回的是true或者false
{
    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;
}

还有格式不是很好,看的不舒服啊,

Sharp your mind!
2011-06-22 11:27
为啥我寂寞
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-6-25
收藏
得分:0 
果断不会
2011-06-25 19:14
lianjiecuowu
Rank: 3Rank: 3
来 自:安徽
等 级:论坛游侠
帖 子:152
专家分:107
注 册:2011-5-20
收藏
得分:0 
回复 5楼 为啥我寂寞
要淡定

Sharp your mind!
2011-06-26 11:00
快速回复:改了很久,还是感觉怪怪的
数据加载中...
 
   



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

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