标题:构造函数的重载求解答~~
取消只看楼主
printf0
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-7-13
结帖率:50%
 问题点数:0 回复次数:0 
构造函数的重载求解答~~
// aa.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;
class Date
{
public:
    Date(int=1,int=1,int=2005);
    Date(int,int,int);
    Date(int,int);
    Date(int);
    void diaplay();
private:
    int month;
    int day;
    int year;
};
Date::Date(int m,int d,int y):month(m),day(d),year(y)
{}
Date::Date(int m,int d):month(m),day(d)
{year=2005;}
Date::Date(int m):month(m)
{day=1;
year=2005;}
void Date::diaplay()
{cout<<month<<"/"<<day<<"/"<<year<<endl;}

int main(int argc, char* argv[])
{
    Date d1(10,13,2005);
    Date d2(12,13);
    Date d3(10);
    Date d4;
    d1.diaplay();
    d2.diaplay();
    d3.diaplay();
    d4.diaplay();

   
    //printf("Hello World!\n");
    return 0;
}

为什么D2,D3的重载不确定呢~~
搜索更多相关主题的帖子: 函数 构造 重载 解答 
2010-10-20 20:06



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




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

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