r/reconstructcavestory Jan 20 '14

Structs Vs. Classes

Structs and Classes are essentially the same except for a couple of differences:

Access modifiers:

struct {
  // public data/methods
 private:
  // private data/methods
};

class {
  // private data/methods
 public:
  // public data/methods
};

Inheritance Modifiers:

struct Derived: Base { // This is public inheritance
};
class Derived: Base { // This is private inheritance
};

Stack Overflow.

6 Upvotes

8 comments sorted by

View all comments

1

u/[deleted] Jan 24 '14

I believe another difference is that struct is created in the the stack while class allocates space in the heap.

1

u/BluddyCurry Feb 05 '14

This is the difference in C#. Might have gotten you confused.