KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
public struct Unit { Unit u; } Causes: Struct member 'Unit.u' of type 'Unit' causes a cycle in the struct layout. But public class Unit { Unit u; } compiles. I understand the problem I suppose. An endless cycle will be formed when referencing a Unit object since it will have to initialize another member Unit and so on. But why does the compiler restrict the problem just for structs ? Doesn't the issue persist for class too? Am I missing something?
Tags (comma-separated)
Save Edits
Cancel