#include "pch.h"
#include <iostream>
#include"time.h"
using namespace std;
int main()
{
time *mytime=new time();
delete mytime;
time mytime1(0);
return 0;
}
#include"pch.h"
#include"time.h"
#include<iostream>
using namespace std;
int time::operator-(const time& a)
{
return hour-a.hour;
}
int time::operator+(const time& a)
{
return hour + a.hour;
}
time::time()
{
p = new char[100];
cout << "调用了time::time()构造函数" << endl;
}
time::time(int tmphour)
{
hour = tmphour;
cout << "调用了time(int tmphour)构造函数" <<endl;
}
time::time(int tmphour, int tmpminute, int tmpsecond) :hour(tmphour), minute(tmpminute), second(tmpsecond)
{
cout << "调用了time::time(int tmphour, int tmpminute, int tmpsecond)构造函数" << endl;
}
time::~time()
{
delete[] p;
cout << "调用了time::~time()析构函数" << endl;
}
#include"pch.h"
#ifndef _time_h
#define _time_h
class time {
public:
int hour;
int minute;
int second;
char *p;
public:
time(int tmphour);
time(int tmphour, int tmpminute, int tmpsecond);
time();
~time();
int operator-(const time& a);
int operator+(const time& a);
};
#endif