Saturday, April 17, 2004

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. 
posted on Saturday, April 17, 2004 9:39:00 PM UTC  #    Comments [0]
Tracked by:
"zen alarm clocks" (online) [Trackback]
"nativity stable" (online) [Trackback]
"male genital massage" (online) [Trackback]
"tiffany mynx mpgs" (online) [Trackback]
"breakfast nook table" (online) [Trackback]
"olga panties" (online) [Trackback]
"bud marijuana pics" (online) [Trackback]
"bed wetting pics" (online) [Trackback]
"uvex sunglasses" (online) [Trackback]
Comments are closed.