is there even a real difference between structs and classes
-
is there even a real difference between structs and classes
-
@[email protected] what language
-
@puppygirlhornypost2 any
in general
because i think theyre almost the same concept -
@[email protected] This is a problem though because it is highly dependent on the language. C#? Structs have their own limitations, there’s classes, records, structs, interfaces, abstract classes, record classes. C++? I have never used struct in my life I only use class declarations. C? There’s no classes only struct.
-
@[email protected] in the most abstract sense, I assume that classes maintain a state. Structs are just data structures. (Yes I used the name in the definition, sue me). Classes have functions, they operate on members of the classes. they can have virtual functions, ones that are overwritten by child classes inheriting from them. Usually you don’t get this with structs. I try to keep structs "pure" without any methods or functions. Sure, I will have functions that take in a struct but my struct will not have functions that modify itself like my classes will.
-
@[email protected] interfaces are interesting in C#… I don’t know how to explain them other than in C++ I am used to headers, I give a skeleton of my class and I define the class in the source file. Interfaces are like the header declaration, they contain things like function prototypes. In C# you can’t inherit from multiple parent classes, but you can implement multiple interfaces.
-
lily :neocat_floof_cute:replied to lily :neocat_floof_cute: last edited by
from how i understand it
structs are used as smaller groupings of data that get passed around
classes are used as a bigger state that is being operated on
depending on the language, their functionality may be exactly the same -
@[email protected] yes.