不是定义对象之后就自动调用构造函数么,为什么什么结果都没有?(语句没错误)
#include "stdafx.h"
#include <iostream>
using namespace std;
class Time
{
public:
Time(int a,int b,int c)
{
hour=a;
minute=b;
second=c;
}
void shuchuT()
{
cout<<hour<<minute<<second<<"\n";
}
private:
int hour;
int minute;
int second;
};
class Date
{
public:
Date(int d,int e,int f)
{
year=d;
month=e;
day=f;
}
void shuchuD()
{
cout<<year<<month<<day<<"\n";
}
void jiayi(int f)
{
cout<<"第二天是"<<f+1<<"号"<<"\n";
}
private:
int year;
int month;
int day;
};
class DateTime :public Time,public Date
{
public:
DateTime(int d,int e,int f,int a,int b,int c): Date(d,e,f),Time(a,b,c)
{
void shuchuD();
void shuchuT();
void jiayi();
}
};
void main()
{
DateTime yitian(2011,9,27,18,55,59);
}