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

前端 未结 6 568
感动是毒
感动是毒 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:16

    In C++, Structs are classes, with the only difference (that I can think of, at least) being that in Structs members are public by default, but in classes they are private. This means it is perfectly acceptable to use Structs as you are - this article explains it well.

提交回复
热议问题