struct - what is it for?

前端 未结 10 2383
小鲜肉
小鲜肉 2020-12-17 23:42

I know something about struct type. But I can\'t understand: what is it for? when have I use it? Classes, simple value-types and enums - that\'s all that I need

10条回答
  •  太阳男子
    2020-12-18 00:04

    In reality, I think struct is an legacy from C. I do not think we MUST use it in any condition. Perhaps sometime you feel that leaving something on stack rather than on heap is more efficient; but as Java/C# never takes efficient as its first stand, so just neglect it:) That's my opinion.

提交回复
热议问题