[.net] Wrap c++ class

Started by
3 comments, last by WahidB 14 years, 7 months ago
Hello, I have a abstract c++ class inside a dll that I want to wrap in .NET this class has alot of virtual functions. I have been searching for hours on google how to wrap this but I couldn't find any good ways. The only way I have found is this one. So my question is, is there a cleaner way to wrap a abstract class in c++/cli. example:

class Foo
{
public:
Foo(){}
virtual ~Foo(){}
virtual void doStuff() = 0;
virtual void doStuff2() = 0;
};




Advertisement
Is this class exported from the DLL?

The thing with virtual function is you'd have to create a derived class that overrides the virtual functions in the DLL(to give them functionality; an intent; a purpose; whatever you wanna call it).

I don't know the specifics with managed C++ but this should be fairly straight-forward if the class is exported from the DLL. http://www.daniweb.com/forums/thread14329.html has some more info. It could also help you if you ask this question in a managed C++ discussion forum.
I already posted it in a C++/CLI forum but no useful solutions so far.
If there are only pure virtual functions the best thing to do might be to define a matching interface in .NET

When there is no implementation at all, why wrap? What's there to wrap?
Quote:Original post by WahidB
Hello,

I have a abstract c++ class inside a dll that I want to wrap in .NET this class has alot of virtual functions. I have been searching for hours on google how to wrap this but I couldn't find any good ways. The only way I have found is this one.
So my question is, is there a cleaner way to wrap a abstract class in c++/cli.


Quote:Original post by ernow
If there are only pure virtual functions the best thing to do might be to define a matching interface in .NET

When there is no implementation at all, why wrap? What's there to wrap?


I already figured out how to do it but it will require some work.

This topic is closed to new replies.

Advertisement