结构-它的作用是什么? [英] struct - what is it for?
本文介绍了结构-它的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 struct
类型有所了解.但是我不明白:这是为了什么?我什么时候使用它?类,简单的值类型和枚举-这就是我所需要的.
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.
有什么建议吗?
UPD:请!不要告诉我struct在堆栈中(我知道这一点:).结构是做什么用的?
UPD: PLEASE! Don't tell me that struct is in the stack (I know this :). What struct is for?
推荐答案
如果需要值类型的语义,请选择一个结构.如果需要引用类型的语义,则选择一个类.其他所有问题都是该问题的次要问题.
You choose a struct if you want value-type semantics. You choose a class if you want reference-type semantics. All other concerns are secondary to this one.
这篇关于结构-它的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文