Winsights

Classes and Structs

Comparison between classes and structs

ClassStruct
Value type
contains reference to object created in memory on heap
Data type
present on stack
Can be sub-classedCan’t be subclassed
No default initialiser?Default initialiser created with all fields as parameters
Contain identifier information in header and consume more memoryLight weight as it doesn’t contain any other information
Tagged with: