gha890826

4/29課輔-private使用

May 13th, 2020 (edited)
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. //private使用
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class c1
  6. {
  7.     public:
  8.         double a=1;
  9.         int turna(){return a; };
  10.         int turnb(){return b; };
  11.     private:
  12.         int c=3,b=2;
  13.         int turnc(){return c;   };
  14. };
  15.  
  16.  
  17.  
  18. int main()
  19. {
  20.     c1 test;
  21.     cout<<test.a<<endl;
  22.     //cout<<test.b<<endl;
  23.     cout<<test.turna()<<endl;
  24.     cout<<test.turnb()<<endl;
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment