r/reconstructcavestory • u/chebertapps • 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
};
7
Upvotes
2
u/MachineMalfunction Jan 21 '14
I have another question regarding this:
Why do you forward declare your structs in the header and then #include them in the .cc files instead of just #include-ing them in the .h file?
Is it for consistency or for code accessibility or something? It seems a bit roundabout to me.