C++ Structs with Member Functions vs. Classes with Public Variables

前端 未结 6 564
感动是毒
感动是毒 2020-12-13 09:30

This is really a question of good form/best practices. I use structs in C++ to form objects that are designed to basically hold data, rather than making a class with a ton o

6条回答
  •  無奈伤痛
    2020-12-13 10:28

    "Use a struct only for passive objects that carry data; everything else is a class."

    say google guidlines, I do it this way and find it a good rule. Beside that I think you can define your own pragmatics, or deviate from this rule if it really makes sense.

提交回复
热议问题