Advertisement
wendy890711

建構函式

Apr 9th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. class student
  7. {
  8. public:
  9. student()
  10. {
  11. ID = 76048;
  12. height = 163;
  13. weight = 47.5;
  14.  
  15. }
  16. void show()
  17. {
  18. cout << "ID=" << ID << endl;
  19. cout << "height=" << height << endl;
  20. cout << "weight=" << weight << endl;
  21. }
  22. private:
  23.  
  24. int ID;
  25. double height, weight;
  26.  
  27. };
  28.  
  29. void main()
  30. {
  31. student me;
  32. me.show();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement