473,472 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help me understand

Hello,

I did some experiments with VC++ 2005, and some ILDasm. Please tell me
if I have understood the concepts of C++ programming under .NET, since
I'm a bit confused!
--
There are 4 types of classes in VC++/CLI:

Unmanaged classes (i.e. normal classes compiled in a unmanaged source
or dll , the code is unmanaged and CPU native). Accessible from C++/CLI
classes but only with a reference (pointer), require a
managed/unmanaged transition for each function call.

Native classes
Standard C++ classes that are compiled with /CLR enabled. These are
marked as native, use the same syntax as standard c++, but compile to
IL (and use the IL CRT). These are not accessible from C#/VB, etc...
but only from C++. Allow for a CLR:Pure compilation, and the code
generated is effectively IL. (you can use framework classes). When an
unmanaged function is called a IJW stub is used.
I don't know if the term "native" is appropriate because on previous
versions it was used as synonym of "unmanaged". Anyway, using ILDasm I
see the "native" tag and IL code.

Value classes
Are .NET classes that can be defined only from C++/CLI, but can be
*used* from other languages too. Are effectively .NET classes value
classes, but could not be instantiated from C# VB. These suffer of many
limitations, so the port of existing C++ classes is not really
confortable.

Ref classes, are "ufficial" .NET classes , used in C++/VB, are accessed
with handles and garbage collected, bla bla bla
In C++ you can use Ref classes by value (and in C# it generates a
different syntax), anyway you need an explicit contructor and
copy/constructor.
--
It is correct? I'm a little confused about native classes. The lack of
value class support in C#/VB is not really good, because it makes
harder to port existing C++ code....
>From what I've understood, Native classes are the key feature to avoid
managed/unmanaged transitions and to port easily your existing code at
least into CLI.... (and that is REALLY good)

Tell me if I'm wrong...
Thanks and sorry for my English!!
QbProg

Dec 14 '06 #1
5 1281
Regarding ref vs value classes and comparison to C# and VB:
ref class -equivalent to C# or VB 'class'
value class -equivalent to C# or VB 'struct'

Note that the C++ 'ref struct' and 'value struct' are not required to
represent C# or VB entities. 'struct' in C++ is identical to a C++ class
except for the default access level.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"QbProg" wrote:
Hello,

I did some experiments with VC++ 2005, and some ILDasm. Please tell me
if I have understood the concepts of C++ programming under .NET, since
I'm a bit confused!
--
There are 4 types of classes in VC++/CLI:

Unmanaged classes (i.e. normal classes compiled in a unmanaged source
or dll , the code is unmanaged and CPU native). Accessible from C++/CLI
classes but only with a reference (pointer), require a
managed/unmanaged transition for each function call.

Native classes
Standard C++ classes that are compiled with /CLR enabled. These are
marked as native, use the same syntax as standard c++, but compile to
IL (and use the IL CRT). These are not accessible from C#/VB, etc...
but only from C++. Allow for a CLR:Pure compilation, and the code
generated is effectively IL. (you can use framework classes). When an
unmanaged function is called a IJW stub is used.
I don't know if the term "native" is appropriate because on previous
versions it was used as synonym of "unmanaged". Anyway, using ILDasm I
see the "native" tag and IL code.

Value classes
Are .NET classes that can be defined only from C++/CLI, but can be
*used* from other languages too. Are effectively .NET classes value
classes, but could not be instantiated from C# VB. These suffer of many
limitations, so the port of existing C++ classes is not really
confortable.

Ref classes, are "ufficial" .NET classes , used in C++/VB, are accessed
with handles and garbage collected, bla bla bla
In C++ you can use Ref classes by value (and in C# it generates a
different syntax), anyway you need an explicit contructor and
copy/constructor.
--
It is correct? I'm a little confused about native classes. The lack of
value class support in C#/VB is not really good, because it makes
harder to port existing C++ code....
From what I've understood, Native classes are the key feature to avoid
managed/unmanaged transitions and to port easily your existing code at
least into CLI.... (and that is REALLY good)

Tell me if I'm wrong...
Thanks and sorry for my English!!
QbProg

Dec 15 '06 #2


On 14 déc, 23:24, "QbProg" <tho...@gmail.comwrote:
Hello,

I did some experiments with VC++ 2005, and some ILDasm. Please tell me
if I have understood the concepts of C++ programming under .NET, since
I'm a bit confused!
--
<snip>
Value classes
Are .NET classes that can be defined only from C++/CLI, but can be
*used* from other languages too. Are effectively .NET classes value
classes, but could not be instantiated from C# VB. These suffer of many
limitations, so the port of existing C++ classes is not really
confortable.

Ref classes, are "ufficial" .NET classes , used in C++/VB, are accessed
with handles and garbage collected, bla bla bla
In C++ you can use Ref classes by value (and in C# it generates a
different syntax), anyway you need an explicit contructor and
copy/constructor.
Value classes are full fledged .NET citizens, and can be created in
other .NET languages. They are called "struct" in C# and "Structure" in
VB.NET. They indeed have some limitations compared to classes, but also
some advantages (eg, they are allocated on the stack, not on the manaed
heap). Anyway, the difference between those 2 types is defined by the
..NET Runtime, and it is not C++ specific in any way.
It is correct? I'm a little confused about native classes.
Why? You can simply see them as usual, normal C++ classes that are
compiled to a different assembly language... Anyway, your wording for
"unmanaged" versus "native" is not official, but if it helps you....
The lack of
value class support in C#/VB is not really good, because it makes
harder to port existing C++ code....
Value classes *ARE* supported in C# or VB !!!

To help you understand those things, you could use .NET Reflector
(Google for it) instead of IldAsm. This tool can dissasemble IL code
and show it as either C# or VB.NET source code. This may help you
understand better what the C++ compiler generates when calling it with
/clr.

Arnaud
MVP - VC

Dec 15 '06 #3


On 14 déc, 23:24, "QbProg" <tho...@gmail.comwrote:
Hello,

I did some experiments with VC++ 2005, and some ILDasm. Please tell me
if I have understood the concepts of C++ programming under .NET, since
I'm a bit confused!
--
<snip>
Value classes
Are .NET classes that can be defined only from C++/CLI, but can be
*used* from other languages too. Are effectively .NET classes value
classes, but could not be instantiated from C# VB. These suffer of many
limitations, so the port of existing C++ classes is not really
confortable.

Ref classes, are "ufficial" .NET classes , used in C++/VB, are accessed
with handles and garbage collected, bla bla bla
In C++ you can use Ref classes by value (and in C# it generates a
different syntax), anyway you need an explicit contructor and
copy/constructor.
Value classes are full fledged .NET citizens, and can be created in
other .NET languages. They are called "struct" in C# and "Structure" in
VB.NET. They indeed have some limitations compared to classes, but also
some advantages (eg, they are allocated on the stack, not on the manaed
heap). Anyway, the difference between those 2 types is defined by the
..NET Runtime, and it is not C++ specific in any way.
It is correct? I'm a little confused about native classes.
Why? You can simply see them as usual, normal C++ classes that are
compiled to a different assembly language... Anyway, your wording for
"unmanaged" versus "native" is not official, but if it helps you....
The lack of
value class support in C#/VB is not really good, because it makes
harder to port existing C++ code....
Value classes *ARE* supported in C# or VB !!!

To help you understand those things, you could use .NET Reflector
(Google for it) instead of IldAsm. This tool can dissasemble IL code
and show it as either C# or VB.NET source code. This may help you
understand better what the C++ compiler generates when calling it with
/clr.

Arnaud
MVP - VC

Dec 15 '06 #4
Thanks for the pointings!!
One last thing:
Why? You can simply see them as usual, normal C++ classes that are
compiled to a different assembly language... Anyway, your wording for
"unmanaged" versus "native" is not official, but if it helps you....
This is where I do not understand. From what I view from ILDast(I'll
try google net reflector soon :)
unmanaged classes are compiled to platform specific assembler code, but
NATIVE classes are still compiled to IL (i.e are not unmanaged but
accessible only from C++/CLI).
Native classes exists even with CLR:Pure (not unmanaged) and use a
modified version of the C Runtime.
I'm wrong?

QbProg

Dec 15 '06 #5

"QbProg" <th****@gmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
Thanks for the pointings!!
One last thing:
>Why? You can simply see them as usual, normal C++ classes that are
compiled to a different assembly language... Anyway, your wording for
"unmanaged" versus "native" is not official, but if it helps you....

This is where I do not understand. From what I view from ILDast(I'll
try google net reflector soon :)
unmanaged classes are compiled to platform specific assembler code, but
NATIVE classes are still compiled to IL (i.e are not unmanaged but
accessible only from C++/CLI).
Native classes exists even with CLR:Pure (not unmanaged) and use a
modified version of the C Runtime.
I'm wrong?
You're not wrong about that.

You are wrong in thinking that only C++/CLI can generate value class types.
The equivalent in C# is the struct keyword.
>
QbProg

Dec 15 '06 #6

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

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
9
by: Daz | last post by:
Hello hello! I'm trying to finish off putting my design into HTML and I've come across a problem that I can't get my head around. I've got divs floating in two columns, but I'm having problems...
3
by: HLong | last post by:
I am trying to understand an example where the Least Significant Bit is replaced. The code is in C# and I am having problems with a line that reads: B= (byte) (Value == 1 ? B | (1 << poss) : B & ~...
0
by: Christopher Ambler | last post by:
This is long, but it's driving me nuts. I need some adult supervision :-) (and I'm not above bribing for help) I have a stored procedure that I call that returns XML to me. The SP returns 3...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
5
by: Y2J | last post by:
I am working through this book on C++ programming, the author is speaking of using linked lists. He gave and example which I found confusing to say the least. So I rewrote the example in a way that...
7
by: Mickyd1561 | last post by:
Hey everyone I'm new to this groups thing and thought maybe someone can help me. My problem is that I can't view specific images on only one website. www.baseballu.net is my baseball team's...
6
by: CD1 | last post by:
#include <string> This code won't compile. There is no variable called "foo2". :)
7
by: sara | last post by:
I have a friend doing some pro-bono work for a non-profit that does job training for distressed kids under DCSS care. He asked me for code to do the following (he's using A2003). I can't find...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.