2021年7月24日 星期六

c++ const method

 一個method被標記為const 表示他不會改變所屬class的member,function若能被標記為const應盡量這麼做

  1. class A{
  2. int b;
  3. void c(){
  4. b = 0; // compiling error
  5. };
  6. };

沒有留言:

張貼留言