C++: When should I use structs instead of classes and where are the speed differences?

前端 未结 5 704
别跟我提以往
别跟我提以往 2021-02-02 10:42
  • When should I use a struct instead of a class? I\'m currently using classes for everything from OpenGL texture wrappers to bitmap fonts.

  • Is

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 11:11

    I like to use classes when I need to have an explicit destructor. Because then, you should be following the rule of three, in which case you need to write a copy constructer and assignment overloader. With all of this, it seems more natural to use a class than a struct.

提交回复
热议问题