什么时候,为什么以及在哪里使用结构? [英] When, why and where should a struct be used?

查看:165
本文介绍了什么时候,为什么以及在哪里使用结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档[1]告诉我如何,但不是何时,为什么或在哪里......


<%= Clinton Gallagher


[1] http:// msdn2。 microsoft.com/en-us/lib...w4(VS.80).aspx

Documentation [1] tells me how but not when, why or where...

<%= Clinton Gallagher

[1] http://msdn2.microsoft.com/en-us/lib...w4(VS.80).aspx

推荐答案

查看此主题:

http://groups.google.com/group/micro...3bcc64b8438f65

Check out this thread:

http://groups.google.com/group/micro...3bcc64b8438f65


Hello clintonG,


话题在2天前提出 http://groups.google.ru/group/micros...7802400b8127a8


c>文档[1]告诉我如何,但不是何时,为什么或在哪里...

c>

c> <%= Clinton Gallagher

c>

c> [1] http:// msdn2。 microsoft.com/en-us/lib...w4(VS.80).aspx

c>

---

WBR,
Michael Nemtsev ::博客: http:/ /spaces.msn.com/laflour


有时一个人仍然忠实于一个事业只因为它的对手没有

停止平淡无奇。 (c)Friedrich Nietzsche
Hello clintonG,

Topic was raised 2 days ago http://groups.google.ru/group/micros...7802400b8127a8

c> Documentation [1] tells me how but not when, why or where...
c>
c> <%= Clinton Gallagher
c>
c> [1] http://msdn2.microsoft.com/en-us/lib...w4(VS.80).aspx
c>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


我会尝试尽可能多地提出一个问题的答案,尽可能多的技术问题...... />

结构是一个旧学校。将数据元素组合成一个单元格的方法。


之后出现了类,它们是一个允许

的结构继承和其他OO之类的东西。


结构稍微简单的生物是精益和平均,即

它们工作速度快但缺乏功能。


示例.NET stucts Point,Rectangle DateTime。注意这些是如何简单的操作通常是性能关键的。


当事情变得更复杂时,类很有用。即你需要

继承或其他东西。


结构和类有不同的pitfals可能会让新的
程序员感到惊讶。 />



a struct不能为nul但是一个类可以..

struct a = stuct b copyies bto a

a类= b类意味着a也称为b。


希望这个基本概述有帮助。


-dm

I will try to give a simle answer gloassing over as many technical
issues as I can...

Structs are an "old school" method of combineing data elements into one
unit.

Class came along afterwards, they are esentuly a struct which allows
for things like inheritance and other OO stuff.

Structs being somewhat simpler creatures are "lean and mean", that is
they work fast but lack features.

Example .NET stucts Point, Rectangle DateTime. Note how these are
simple operations which are often performance critical.

Classes are usefull when things get more complicated. Ie you need
inheritance or something.

Struct and Classes have different pitfals that may suprise the new
programmer.
ie

a struct can not be nul but a class can..
struct a = stuct b copyies bto a
class a = class b means a is also called b.

hope this "basic" overview helps.

-dm


这篇关于什么时候,为什么以及在哪里使用结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆