Class VS Struct

1、在语言层面:class的default member访问方式和继承方式为private,struct的default member访问方式和继承方式为public。

2、Struct:

  small passive objects that carry public data and have no or few basic member function.

  Data Contain

 Class: Bigger active objects that carry private data, interfaced through public function

    Complex Data structure

Summary:

  // 1.Use struct for passive objects with public data, use class for active objects with private data.

    // 2.Use setter/getter to access class's data

  // 3. Avoid making setter/getter if possible.

   

posted @ 2018-11-22 20:39  看!前方  阅读(82)  评论(0)    收藏  举报