Re: C++ vs. C#
On 31 Dez., 00:41, tonytech08 <tonytec...@gmail.com> wrote:
On Dec 28, 2:28 am, SG <s.gesem...@gmail.com> wrote:
I obviously don't know what you are talking about and I'm guessing
I'm not the only one. So in case you want this thread to have any
responses that are worth reading you might want to reconsider
explaining yourself (w.r.t. lightweight concept) "again" or at least
point to some resource containing the definitions you use.
At this point, after having read up on C#'s usage of the terminology,
I'll refer the reader there. While it's not necessarily my take or
whole take on the concept, it should suffice to introduce the
unitiated. Look at the C# documentation for the definition that MS
gives to 'struct', 'class' and note the use of the term 'lightweight'.
You have to do better than saying "look up the C# documentation". I
didn't find any definition of "lightweight". But the way this word is
used suggests that Microsoft likes to call value types "lightweight":
"The struct type is suitable for representing lightweight objects
such as Point, Rectangle, and Color. Although it is possible to
represent a point as a class, a struct is more efficient in some
scenarios. For example, if you declare an array of 1000 Point
objects, you will allocate additional memory for referencing each
object. In this case, the struct is less expensive."
"In C#, a struct is like a lightweight class; it is a stack-
allocated type that can implement interfaces but does not support
inheritance."
In case you havn't noticed in C++ neither structs nor classes define
types that behave like references and thus would qualify as being
lightweight.
Also, then do a search within that documentation for facilities that
give the developer strict control over the layout of fields within
structs/lightweight classes.
Can you provide more specific pointers? BTW: What do you care about
the layout of fields? C# (at first glance) doesn't support accessing
the raw data of objects. So there's no way to tell how the fields are
laid out in memory, is there?
Cheers!
SG