Is there any advantage over using a class over a struct in cases such as these? (note: it will only hold variables, there will never be functions)
class Foo
If the contents of the type have no memory allocation issues (such as plain int), then using struct
is fine if that's the way you want to go and you've made a conscious decision about it that you can justify to those who use your code. However, if any of the members is a pointer type, then you need to think hard about the memory management issues. It may still be OK to use a struct
, but you are much more likely to need a destructor, and some constructors, and so on. At that point, you want a class
.