Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

void* equivalent

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nanditha Chandra - 16 Sep 2004 20:59 GMT
Hi!

I am new to Managed C++ and am working on my first project with this.

In native C++, we could have a function that takes void* and call that
function with any type. Is there a way to do that with MC++? If I had
something as follows in native C++,

Foo(void* arBuf, int nSize);

And this can be called as follows

int* nBuf = new int[nSize];
Foo(nBuf, nSize);

long* nBuf2 = new long[nSize];
Foo(nBuf2, nSize);

How would I do something like this in MC++? I have an array of Byte
and int (and possibly others as well). And I need to pass this to a
function which can handle both (Similar to the Foo function above). I
am not sure how that Foo function has to be defined in MC++?

Also an additional question - What exactly is IntPtr? Is it void
equivalent?

Thanks,
D
Tomas Restrepo \(MVP\) - 17 Sep 2004 00:41 GMT
Nanditha,

> I am new to Managed C++ and am working on my first project with this.
>
[quoted text clipped - 16 lines]
> function which can handle both (Similar to the Foo function above). I
> am not sure how that Foo function has to be defined in MC++?

You'd probably want Object*, since all managed types derive from Object.
That said, you'd need to box value types...

> Also an additional question - What exactly is IntPtr? Is it void
> equivalent?
Not quite. It is mostly used for interop where you need to handle values of
pointers (possibly pointing to unmanaged memory).

Signature

Tomas Restrepo
tomasr@mvps.org


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.