Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:17:07+00:00 2026-06-17T05:17:07+00:00

I am just curious about C++/CLI handle(^) and how it works. For e.g: The

  • 0

I am just curious about C++/CLI handle(^) and how it works. For e.g:

The first thing that I cannot understand is, over here the accepted answer says that the caret is the managed equivalent of a * (pointer). However, unlike *, I can directly assign value to ^.

int ^num;
num = 4;

This would not work in C++:

int *num2;
num2 = new int[1];
num2 = 10;

Why is this behavior observed?
Also, in Microsoft Webpage they say you cannot point to a member of the object, and it does not support pointer arithmetic. So both the following code snippet would fail to compile

int ^num3 = gcnew int[10];

for(int i = 0; i<10; i++)
    %(num3 + i) = i

or

for(int i = 0; i<10; i++)
    (num3 + i) = i

Why???

That brings me to final question: What would be equivalent of following int native/normal C++ code snippet in C++/CLI?

int *array1;
array1 = new int[ 10];

for( int i = 0; i < 10; i++)
     *(array1 + i ) = i;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:17:08+00:00Added an answer on June 17, 2026 at 5:17 am

    ^ is the equivalent of *, for the purposes of dealing with class objects (new/gcnew, passing as parameters, storing as part of a class definition, etc). Pointer arithmetic isn’t the same in C++/CLI.

    Here’s the equivalent to your code snippet:

    array<int>^ array1;
    array1 = gcnew array<int>(10);
    
    for (int i = 0; i < 10; i++)
        array1[i] = i;
    

    array<int>^: This is a managed reference, stored on the stack.

    array1 = gcnew array<int>(10): This is creating a managed object (from the class named “array”) on the managed heap, and assigning the reference to the local variable on the stack.

    array1[i] = i: Behind the scenes, this calls a method on the “array” class, passing it the index and the new value (both i in this case).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just curious. I heard something about the new G1GC addressing that latency problem. I
Just curious about it... Cedric Beust created TestNG and I understand from an interview
Just curious about how jaxb works, I have a class annotated as follows: @XmlRootElement(name
I am just curious about the role that self plays within an object. I
i was just curious about webbot project and i wish that i could create
Basically, I'm just curious about the history. When was the first linker written? What
I am just curious about the java memory model a little. Here is what
I'm mostly just curious about this. Do assemblies that would be considered part of
I'm just curious about if letting installed some snippets that are not essentials to
Just curious about which of these would be faster? $('ul.dropdown a').first().click(function(event) { event.stopPropagation(); return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.