lobsang_ludd t1_ixdcsy2 wrote
Struct: a bundle of data combining some set of named fields of different (potentially overlapping) types. It models an "AND" relationship between its fields, asserting that at some point in the system state they were all true together. It has no behaviour, and its data cannot be changed - although you can make a copy with a different value in a particular field.
Class: A bundle of data with behaviours. It has some set of methods that can be used to act on it, changing the data in accordance with the rules defined by its programmers. Classes can have an inheritance hierarchy, where instances of a derived class can use code from the parent class or an override method in their own class.
Constructor: A special case of the methods of a class, which is run when a new instance of the class is made. It's generally responsible for ensuring the assumptions made by other methods will be true.
Triabolical_ t1_ixg5kej wrote
Both structs and classes in C# have methods.
This is true in C++ as well.
Viewing a single comment thread. View all comments