プログラムはずっと间违っていて、どのように直すべきか分かりません.
1856 ワード
/*
* Copyright (c)2013,
* All rightsreserved.
* : array.cpp
* :
* :2014 5 14
* : v1.0
* :
*/
#include <iostream>
using namespace std;
class Date
{
public:
void SetDate(int y,int mo,int d)
{
year=y;
month=mo;
day=d;
}
void PrintDate()
{
cout<<year<<"."<<month<<"."<<day;
}
protected:
int year;
int month;
int day;
};
class Time
{
public:
void SetTime(int h,int mi,int s)
{
hour=h;
minute=mi;
second=s;
}
void PrintTime()
{
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
protected:
int hour;
int minute;
int second;
};
class TimeDate:public Date,public Time
{
public:
TimeDate(int y,int mo,int d,int h,int mi,int s):
Date(y,mo,d),Time(h,mi,s){};
void PrintDate_Time()
{
PrintDate();
cout<<" ";
PrintTime();
}
}
int main()
{
TimeDate dt_a,dt_b(2010,4,16,9,30,0);
cout<<"dt_a: ";
dt_a.PrintDate_Time();
cout<<endl;
cout<<"dt_b: ";
dt_b.PrintDate_Time();
dt_a.SetTime(20,00,00);
dt_a.SetDate(2008,8,7);
cout<<endl;
cout<<"dt_after uptate: ";
dt_a.PrintDate_Time();
return 0;
}