Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //將值傳入一併建構
- #include <iostream>
- using namespace std;
- class time
- {
- public:
- time(int a,int b,int c)
- {
- cout<<"建構time\n";
- hour=a;
- min=b;
- sec=c;
- }
- void show(){cout<<hour<<":"<<min<<":"<<sec<<endl;}
- private:
- int hour,min,sec;
- };
- int main()
- {
- time t1(1,2,3);
- t1.show();
- return 0;
- }
- /* time t1,t2(2),t3(3,3,3),t4(0,0,4);
- t1.show();
- t2.show();
- t3.show();
- t4.show();*/
Add Comment
Please, Sign In to add comment