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

后端 未结 19 2323
礼貌的吻别
礼貌的吻别 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 09:59

    You could look at what the Standard Library does. Everyone's favourite struct std::pair only has constructors.

    I find the use of constructors with structs so convenient and natural that I can't imagine doing without them. I never give structs any other methods, but of course there may be free functions or members of other classes that take them as parameters.

提交回复
热议问题