I consider myself as an enthusiast in learning new things everyday, about our history and future as well as the present. My interests: Ancient History, Comparative Religion, Science and Tech, C++
struct and classes looks like the same thing, but using the keyword class instead of struct gives an indication to the reader (of your code) that you are trying to abstract a real world concept into your class. For example, it can be an abstraction/conceptualisation of the animal kingdom,
i.e, a human inherits its traits from a mammal which inherits from animal. Yes, you can use the keyword struct too, but usually struct should be used to conceptualise a data structure to pass around for use, for example a leaf node inside a tree. Yes, classes and structures are interchangeable but following a convention shows professionalism and intention behind the code.
This is a really great response, and aligns pretty well with the intuition I'd sort of already been building. Thanks for putting it so clearly, I will keep this in mind.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
struct and classes looks like the same thing, but using the keyword class instead of struct gives an indication to the reader (of your code) that you are trying to abstract a real world concept into your class. For example, it can be an abstraction/conceptualisation of the animal kingdom,
i.e, a human inherits its traits from a mammal which inherits from animal. Yes, you can use the keyword struct too, but usually struct should be used to conceptualise a data structure to pass around for use, for example a leaf node inside a tree. Yes, classes and structures are interchangeable but following a convention shows professionalism and intention behind the code.
This is a really great response, and aligns pretty well with the intuition I'd sort of already been building. Thanks for putting it so clearly, I will keep this in mind.