In C++, there’s very little difference between a
class and a
class defaults to
private access and a
struct defaults to
public access. There are no other technical differences between the two, though by convention, they are often used for different things.
C# is a language that mimics the syntax of C++ to some degree, and also has
struct. However, in this case, the technical difference is quite large! In this post, I’ll briefly explain that difference and highlight a scenario where using a
struct saved me a lot of memory on a project I’m working on.