473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Questions on __value class

Hi,

In C#, value types are derived from System.ValueType (and hence from
System.Object).

Does this hold true for MC++?

__value class ValueClass {...};

Is ValueClass above derived from System::ValueType (and hence from
System::Object)?

Thanks,
Simon
Nov 17 '05 #1
5 1198
Simon Cheng wrote:
In C#, value types are derived from System.ValueType (and hence from
System.Object).

Does this hold true for MC++?

__value class ValueClass {...};

Is ValueClass above derived from System::ValueType (and hence from
System::Object)?


Yes.

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
Nov 17 '05 #2
Simon Cheng wrote:
__value class ValueClass {...};


For more info see: __value Classes
http://msdn.microsoft.com/library/en-
us/vcmxspec/html/vcManagedExtensionsSpec_5.asp

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
Nov 17 '05 #3
Thanks, Jochen. The next question:

The derivation chain for ValueClass is:

System::Object
System::ValueType
ValueClass

Why objects derived from System::ValueType (_indirectly_ from
System::Object) are always allocated on stack, whereas objects derived
_directly_ from System::Object are always allocated on CLR heap? This means
if a value object calls a method inherited from System::Object but doesn't
override it, then the object needs to be boxed before the call can be made.
Is this just how it is designed?

Simon

"Jochen Kalmbach" <no********************@holzma.de> wrote in message
news:Xn**********************************@207.46.2 48.16...
Simon Cheng wrote:
__value class ValueClass {...};


For more info see: __value Classes
http://msdn.microsoft.com/library/en-
us/vcmxspec/html/vcManagedExtensionsSpec_5.asp

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/

Nov 17 '05 #4
Simon Cheng wrote:
The derivation chain for ValueClass is:

System::Object
System::ValueType
ValueClass

Why objects derived from System::ValueType (_indirectly_ from
System::Object) are always allocated on stack, whereas objects derived
_directly_ from System::Object are always allocated on CLR heap? This means
if a value object calls a method inherited from System::Object but doesn't
override it, then the object needs to be boxed before the call can be made.
Is this just how it is designed?


That's pretty accurate. Here are a couple of articles that give some
background on value types:

CLR Design Choices
A Conversation with Anders Hejlsberg, Part VIII
Value Types
http://www.artima.com/intv/choices3.html

Value Types
http://blogs.msdn.com/cbrumme/archiv.../10/51425.aspx
--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #5
Thanks for the pointers. They are good read.

Simon

"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message
news:o7********************************@4ax.com...
Simon Cheng wrote:
The derivation chain for ValueClass is:

System::Object
System::ValueType
ValueClass

Why objects derived from System::ValueType (_indirectly_ from
System::Object) are always allocated on stack, whereas objects derived
_directly_ from System::Object are always allocated on CLR heap? This meansif a value object calls a method inherited from System::Object but doesn'toverride it, then the object needs to be boxed before the call can be made.Is this just how it is designed?


That's pretty accurate. Here are a couple of articles that give some
background on value types:

CLR Design Choices
A Conversation with Anders Hejlsberg, Part VIII
Value Types
http://www.artima.com/intv/choices3.html

Value Types
http://blogs.msdn.com/cbrumme/archiv.../10/51425.aspx
--
Doug Harrison
Microsoft MVP - Visual C++

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
3
by: Edward Diener | last post by:
In the doc regarding __value classes, under Primitive Types, I read: "Generally, the C++ types and their __value class equivalents are interchangeable in Managed Extensions." What exactly does...
8
by: Edward Diener | last post by:
I have a __value class which uses some legacy C++ code. So I wrapped the legacy C++ code in another __nogc class and have a pointer to that class as a member of my __value class. When the __value...
0
by: Edward Diener | last post by:
If a __value class with an event is put into an assembly, and a __gc class in another assembly attempts to attach its own event handler to the __value class's event of an embedded object of the...
0
by: Edward Diener | last post by:
Why is there a prohibition of instantiating __value type enums and classes within __nogc classes ? After all __value types are not managed by the GC and built-in __value types, such as 'int', are...
15
by: Edward Diener | last post by:
Why is it impossible to have a __value class instance variable in a __nogc class when it is possible to have a built-in type instance variable in a __nogc class ? __value class X { int a; };...
1
by: Bae,Hyun-jik | last post by:
Where are __value objects allocated? I guess __value object is same to basic __value objects such as int,char,float, but C# compiler demands using new keyword even to __value classes. Please...
0
by: Marcus Kwok | last post by:
I have been reading through the ManagedExtensionsSpec.doc file and I thought something was not clear. If I have a __value class (really a __value struct but that shouldn't make a difference) and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.