构造函数的重载求解答~~
// 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的重载不确定呢~~