How much functionality is “acceptable” for a C++ struct?

后端 未结 19 2329
礼貌的吻别
礼貌的吻别 2021-02-07 09:31

My first post so please go easy on me!

I know that there\'s no real difference between structs and classes in C++, but a lot of people including me use a struct or class

19条回答
  •  粉色の甜心
    2021-02-07 10:00

    If there's accesser methods for the data members then it's a class.

    If you have direct access to the data and can modify it at will, it's a struct.

    There's no reason a struct shouldn't have constructors, comparison operators, etc.

提交回复
热议问题