Consider the simple and tedious task of wrapping C++ classes into Managed C++ (MC++). The classic approach is to make a proxy around an instance of the C++ class allocated on the heap:
// the C++ class
class A {...};
// the MC++ wrapper
public __gc class MA
{
A* a;
public:
MA() { a = new A();}
~MA() { delete a;}
}
This works well for individual classes (although it is a tedious work) but it fails when it comes to map inherance. Let's add a second class to our example:
class A
{
public:
virtual void method();
};
class B : public A
{
public:
virtual void method();
}
The proxies for A,B should map the inherance the original classes, therefore I would expect to have something like this:
public __gc class MB : MA
{
???
}Now, the question is: where should I instanciate B, where should I store the pointer without making ugly casts all over-the-place. The answer is simple: Stop MC++ and wait C++/CLR announced in a near future.