gha890826

4/29課輔-private講解

May 13th, 2020 (edited)
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 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.         };
  11.     private:
  12.         int c=3;
  13.         int turnc(){return c;
  14.         };
  15. };
  16.  
  17. int main()
  18. {
  19.     c1 test;
  20.     cout<<test.a<<endl;
  21.     //cout<<test.c<<endl;
  22.     cout<<test.turna()<<endl;
  23.     //cout<<test.turnc()<<endl;
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment