When writing C++ code, what is the difference between using class
and struct
?
class Foo final { };
vs.
struct Bar final { };
When should I prefer one over the other? Is this merely a choice of programming/coding style?
When writing C++ code, what is the difference between using class
and struct
?
class Foo final { };
vs.
struct Bar final { };
When should I prefer one over the other? Is this merely a choice of programming/coding style?
A struct
simply defines the layout of a piece of storage.
A class
is a dynamically-allocated "thing" which can have methods ... it can do things.