实际上c++的类,最后也是转为结构体实现的。主要区别:

  • All members of a struct are public by default
  • All members of a class are private by default
    在什么情况下使用:
    We use structs only when we want a simple type with little or no methods
    and direct access to the data members (as a matter of style)