| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 487 人关注过本帖
标题:帮忙找下错误吧 谢谢!
只看楼主 加入收藏
winnerflyer
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2008-3-14
收藏
 问题点数:0 回复次数:2 
帮忙找下错误吧 谢谢!
//Date.h
class Date
{
public:
    void setDate(int,int,int);
    Date(int y,int m,int d);
    Date::Date()
{
    year=month=day=0;
}


    int getYear();
    int getMonth();
    int getDay();
private:
        int year;
        int month;
        int day;

};


//成员函数
void Date::setDate(int y,int m,int d)
{
    year=(y>=0&&y<=12)?y:0 ;
    month=(m>=0&&m<=12)?m:0 ;
    switch(m)  ///某个月的天数的具体分析
    {
    case '1':;
    case '3':;
    case '5':;
    case '7':;
    case '8':;
    case '10':;
    case '12':;  day=(d>=0&&d<=31)?d:0; break;
    case '4':;
    case '6':;
    case '9':;
    case '11':; day=(d>=0&&d<=30)?d:0 ; break;
        default: if(  ( (y%4==0)&&(y%100!=0) )||(y%400==0) )  //判断瑞年2月的天数是否合法
                     day=(d>=0&&d<=29)?d:0 ;
               else  day=(d>=0&&d<=28)?d:0 ;
                break;


    
    
}

//日期值的输出函数
int Date::getYear()
{
    return year;
}


int Date::getMonth()
{
    return month;
}


int Date::getDay()
{
    return day;
}


//测试函数
#include <iostream.h>
#include "Date.h"

void main()
{
    Date d;
    cout<<"原始时间是(年-月-日的方式输出):"<<d.getYear()<<"-"<<d.getMonth()<<"-"<<d.getDay()<<endl;

    d.setDate(1,5,31);

    cout<<"合法修正后的时间输出是:"<<d.getYear()<<"-"<<d.getMonth()<<"-"<<d.getDay()<<endl;


}
搜索更多相关主题的帖子: 分析 private public 
2008-03-14 11:19
xianshizhe111
Rank: 1
等 级:新手上路
帖 子:1451
专家分:0
注 册:2007-12-8
收藏
得分:0 
发到C++.
2008-03-14 11:54
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
我已经帮他找了..少了个大括号

学习需要安静。。海盗要重新来过。。
2008-03-14 12:10
快速回复:帮忙找下错误吧 谢谢!
数据加载中...
 
   



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

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