all groups > dotnet clr > september 2007 >
You're in the

dotnet clr

group:

Pointers in VC.Net


Pointers in VC.Net Dipesh_Sharma
9/27/2007 11:22:01 PM
dotnet clr:
Hi All,
I am new on this VC.Net platform, So please dont mind to my question.
In VC++ we can use pointers very easily, but i want to know if we can use:
int *ptr = new int[10];
and
char * in VC.net.
If we cant use them whats the alternate option for them. Please explain me
this or provide me link to answers to these question.

Re: Pointers in VC.Net Willy Denoyette [MVP]
9/28/2007 12:00:00 AM
[quoted text, click to view]


This is not the right NG to ask VC question, please post to the VC NG
instead.

Willy.
Re: Pointers in VC.Net Ben Voigt [C++ MVP]
10/3/2007 12:47:56 PM

[quoted text, click to view]

That works. There's also a syntax for pointers into .NET objects, which
looks like this:

array<int>^ a = gcnew array<int>(10);
interior_ptr<int> ptr = &a[0];

[quoted text, click to view]

which is microsoft.public.dotnet.languages.vc

[quoted text, click to view]

Re: Pointers in VC.Net Andrew Faust
10/30/2007 12:34:50 AM
Ben answered the question already. However, I just wanted to point out that
you may not actually need to create a pointer for your specific needs
anymore. The .Net platform supports passing objects around as references
automatically. For example you can do this:

MyClass class = new MyClass();
object o1 = class;
object o2 = o1;
object o3 = o2;
MyClass class2 = o3;

After that sequence of events class, o1, o2, o3 & class2 will all be
pointing at the exact same instance of MyClass object.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com


[quoted text, click to view]
Re: Pointers in VC.Net Ben Voigt [C++ MVP]
11/8/2007 9:27:27 AM

[quoted text, click to view]

What language are you using? Neither C# nor C++ support implicit downcast.
Also "class" is a keyword in most languages and can't be used as a variable
name.

[quoted text, click to view]

AddThis Social Bookmark Button