Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Equivalent of "object of C# " in VC++?

In C# we have a datatype object which can hold any type of data. Same thing I want to achieve in VC++. Can anyone kindly let me know VC++ equivalent of "Object of C#".
IN C#, in the calling appl program (say call.cs)

object ob=null;
ob=(object)str; 
 funct(ref ob);

Here str is empty string.

This thing I want to achieve in VC++. So I need to create VC++ equivalent of object. I am sure we need to use pointers as ref's equivalent??

like image 812
codeLover Avatar asked Nov 27 '22 12:11

codeLover


1 Answers

There isn't one. C++ doesn't have a unified type hierarchy like .NET languages have.

The closest you can get is a void* (pointer-to-void), which can point to any type of object. You should avoid void*s like the plague, though; once you start using them you lose any and all type safety.

like image 70
James McNellis Avatar answered Dec 05 '22 07:12

James McNellis