473,407 Members | 2,320 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.

The effect of "^"

Hi, All!

What is the effect of using ^ with the managed type? I'm trying to create a
class library in managed c++. There is a class:

public ref class MyClass

{

public:

IntPtr^ WindowHandle;

int^ SomeNumber;

};

When I use this class in another project (C#) it is shown as

public class MyClass

{

public ValueType SomeNumber;

public ValueType WindowHandle;

public MyClass();

}

When I use type declarations without "^" the imported class becomes

public class MyClass

{

public int SomeNumber;

public IntPtr WindowHandle;

public MyClass();

}

I thought that I should always use ^ with managed classes. Could somebody
explain me that? Sorry for such a stupid question, but I'm new to Managed
C++.

Thanks in advance.

Feb 18 '07 #1
2 954
The normal use of "^" is with reference types, not value types, so you would
normally not use it with 'int' for example, but you would use it with
'System::String' for instance.
--
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: C#/VB to Python converter
"Maxim" wrote:
Hi, All!

What is the effect of using ^ with the managed type? I'm trying to create a
class library in managed c++. There is a class:

public ref class MyClass

{

public:

IntPtr^ WindowHandle;

int^ SomeNumber;

};

When I use this class in another project (C#) it is shown as

public class MyClass

{

public ValueType SomeNumber;

public ValueType WindowHandle;

public MyClass();

}

When I use type declarations without "^" the imported class becomes

public class MyClass

{

public int SomeNumber;

public IntPtr WindowHandle;

public MyClass();

}

I thought that I should always use ^ with managed classes. Could somebody
explain me that? Sorry for such a stupid question, but I'm new to Managed
C++.

Thanks in advance.

Feb 18 '07 #2

"Maxim" <vmu_at_mail_dot_rua écrit dans le message de news:
uo*************@TK2MSFTNGP06.phx.gbl...
Hi, All!

What is the effect of using ^ with the managed type? I'm trying to create
a class library in managed c++. There is a class:

public ref class MyClass

{

public:

IntPtr^ WindowHandle;

int^ SomeNumber;

};

When I use this class in another project (C#) it is shown as

public class MyClass

{

public ValueType SomeNumber;

public ValueType WindowHandle;

public MyClass();

}

When I use type declarations without "^" the imported class becomes

public class MyClass

{

public int SomeNumber;

public IntPtr WindowHandle;

public MyClass();

}

I thought that I should always use ^ with managed classes. Could somebody
explain me that? Sorry for such a stupid question, but I'm new to Managed
C++.
Yes, you should always use ^ with managed *classes* (that is, reference
types, which are written "class" in C#). The problem is that both IntPtr and
int are value types ("struct" or primitive type in C#). They are therefore
created on the stack (as opposed to the managed heap) and don't require the
caret.

Arnaud
MVP - VC
Feb 18 '07 #3

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

Similar topics

17
by: Tobiah | last post by:
Ok, I miss the idiom that my other languages use, something like: while( foo = getmore()){ process(foo); }
145
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
0
by: Charles | last post by:
I'm being tortured by this warning: Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. ... I've looked the code up and down and I'm no...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
10
by: Kurda Yon | last post by:
Hi, I set the register_globals off and try to get my code working under the new conditions. I stuck on the following problem: Warning: Unknown(): Your script possibly relies on a session side-...
0
by: diegocami | last post by:
Hi everyone!, I need some directions on how to get my "sweeping bar effect" to work, I´ll try to explain myself: Situation: I have a couple of buttons that should attach (that´s the method I´m...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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,...
0
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...

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.