啪啪拉拉噼里啪啦

初学者天堂资料汇集

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  16 随笔 :: 73 文章 :: 16 评论 :: 0 Trackbacks

#include<iostream.h>
class Clock
{public:
  Clock(int NewH=2,int NewM=30,int NewS=39);
  Clock (Clock &P);
  void SetTime(int NewH,int NewM,int NewS);
  void ShowTime();
 private:
  int Hour,Minute,Second;
};
void Clock::SetTime(int NewH,int NewM,int NewS)
{ Hour=NewH;
  Minute=NewM;
  Second=NewS;
}
Clock::Clock(int NewH,int NewM,int NewS)
{ Hour=NewH;
  Minute=NewM;
  Second=NewS;
}
inline void Clock :: ShowTime()
{ cout<<Hour<<":"<<Minute<<":"<<Second<<endl;
}
Clock::Clock(Clock &P)
{ Hour=P.Hour;
  Minute=P.Minute;
  Second=P.Second;
  cout<<"拷贝构造函数调用"<<endl;
}
void fun1(Clock thisClock)
{ thisClock.ShowTime;
}

Clock fun2()
{Clock aa(1,2,3);
 return aa;
}
void main()
{ Clock myclock;
  Clock cc(1,2,3);
  Clock yourclock(myclock);
  Clock dd;
  cout<<"Please settime first"<<endl;
  myclock.SetTime(0,0,0);
  myclock.ShowTime();
  cout<<"the appear two vido"<<endl;
 myclock.SetTime(8,30,52);
  myclock.ShowTime();
  cout<<"please three appear"<<endl;
  cc.ShowTime();
 cout<<"please four appear"<<endl;
 yourclock.ShowTime();
 fun1(yourclock);
 dd=fun2();
 dd.ShowTime;
}

 

posted on 2005-04-03 16:41 噼里啪啦的世界 阅读(150) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: