程序为什么连析构函数也不调用,还有不输出bTime,cTime两个对象
程序为什么连析构函数也不调用,还有不输出bTime,cTime两个对象.#include<iostream>
using namespace std;
class Time{
public:
Time(int hour,int minute,int second);
Time(const Time& t);
~Time();
void showTime();
private:
int hrs,mins,secs;
};
Time::Time(int hour,int minute,int second){
hrs=hour;
mins=minute;
secs=second;
}
Time::Time(const Time& t){
Time s(t);
hrs=s.hrs;
mins=s.mins;
secs=s.secs;
}
Time::~Time()
{cout<<"Destruction is called"<<endl;}
void Time::showTime()
{cout<<hrs<<":"<<mins<<":"<<secs<<endl;}
int main(){
cout<<"<<<Object Tnitiallizations uing the\''copy constructor\">>>"<<endl;
Time aTime(10,20,30);
cout<<"the Time stored in aTime is";
aTime.showTime();
Time bTime=aTime;
cout<<"the Time stored in bTime is";
bTime.showTime();
Time cTime(bTime);
cout<<"the Time stored in cTime is";
cTime.showTime();
cout<<"End of my act!"<<endl;
return 0;
}