注册 登录
编程论坛 VC++/MFC

求解为什么time1出错?

henhenlu 发布于 2013-11-02 13:54, 384 次点击
#include<iostream>
using namespace std;
class Time
{
      public:
             Time(int hour=0,int min=0,int sec=0);
             int compute();
      
                     int hour;
                     int min;
                     int sec;
                     };
                     Time::Time(int h,int m,int s)
                     {
                                    hour=h;
                                    min=m;
                                    sec=s;
                                    }
                                    int Time::compute()
                                    {
                                        return(hour*min*sec);
                                        }
                                        int main()
                                        {
                                            Time time1();
                                            cout<<"The hour is:"<<time1.hour<<endl;
                                            Time time2(6,2,4);
                                            cout<<"The hour is:"<<()<<endl;
                                            Time time3(1,2,3);
                                            cout<<"The hour is:"<<()<<endl;
                                       system("pause");
                                            }
2 回复
#2
yuccn2013-11-02 23:19
你输出是什么?你期待的是什么?

楼主,缩进太难看了
#3
henhenlu2013-11-03 12:23
您说的有道理啊
1