Usage preference between a struct and a class in D language
问题 When should I define a type as a struct or as a class? I know that struct are value types while classes are reference types. So I wonder, for example, should I define a stack as a struct or a class? 回答1: Reason #1 to choose struct vs class: classes have inheritance, structs do not. If you need polymorphism, you must use classes. Reason #2: structs are normally value types (though you can make them reference types if you work at it). Classes are always reference types. So, if you want a value