你们可以试试这个程序:
#include<iostream>
using namespace std;
class Time{
public:
int hour;
int minute;
int sec;
void Show()
{
cout<<hour<<":"<<minute<<":"<<sec<<endl;
}
Time(int h,int m,int s);
Time(){}
~Time(){
cout<<"调用了析构函数:"<<endl;
}
};
Time::
Time(int h,int m,int s):hour(h),minute(m),sec(s)
{
cout<<"调用了构造函数;"<<endl;
}
class Stu{
private:
int num;
float f;
void Show()
{
cout<<num<<":"<<f<<":"<<endl;
}
};
int main()
{
Time t[50]={Time(34,21,56),
Time(24,21,56),
Time(4,1,56),
Time(14,21,56)};
return 0;
}