Sign in to follow this  
WahidB

[.net] Wrap c++ class

Recommended Posts

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;
};




Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this