Re: Pointers in VC.Net




"Andrew Faust" <andrew@xxxxxxxxxxxxxxx> wrote in message
news:48CF31CB-2D63-4A3C-8DAF-A9F3929C1C91@xxxxxxxxxxxxxxxx
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;

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.


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


"Dipesh_Sharma" <DipeshSharma@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C631831B-F7E4-4D2E-919D-6A698C4D5A1B@xxxxxxxxxxxxxxxx
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.

Thanks.



.



Relevant Pages

  • Re: Pointers in VC.Net
    ... 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. ... MyClass class = new MyClass; ...
    (microsoft.public.dotnet.framework.clr)
  • Re: why no copy constructor in java?
    ... Here only the pointer value is copied, both pointers will then point to ... MyClass Obj_1 = MyClass; ... default memberwise shallow copy then Obj_1 and Obj_2 will both have ... > behaviour(shallow copying) is usually un-acceptable. ...
    (comp.lang.java.programmer)
  • Re: TRICK: Unique IDing
    ... > pointer to the target instance or a pointer to a copy of the target ... When passing an instance of a class it can be done so the ... > class MyClass ... > you want ) and compare it against the suspect. ...
    (microsoft.public.dotnet.languages.vc)
  • TRICK: Unique IDing
    ... Sometimes it's hard to get straight when passing or storing or returning an ... pointer to a copy of the target instance. ... class MyClass ... ID) and compare it against the suspect. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Conversion from void* to a point of a class
    ... Well, that is true, dynamic_cast does not work for void-pointers - once you have converted your MyClass* pointer to a void* you have voluntarily given up all type information and there is no safe way back. ...
    (microsoft.public.dotnet.languages.vc)

Loading