Inheritance in managed c++.

A

A n g l e r

Hello everybody. I've got a bizarre problem concerning inheritance of
the managed c++ code when using templates. Consider the following
wrapper for the unmanaged c++ class:



template <typename SomeType>

public ref class SomeManagedClass

{

private:

SomeType* pSomeObj;

public:

SomeManagedClass(void) { pSomeObj=new SomeType(); }

~EyeTouchProcBaseManaged(void) { SAFE_DELETE(pSomeObj); }

void Method1(void) { pSomeObj->Method1(); }

}



Now let's derive a new managed wrapper that specializes it a bit
further:

public ref class SomeManagedClassDer : public SomeManagedClass<SomeType>

{

public:

SomeManagedClassDer(void) : SomeManagedClass() { };

};



When using an object of the derived class SomeManagedClassDer in c# I
cannot access the Method1 method (according c#, it does not contain the
definition - although it's expected to be inherited). Does anyone know
why?! If the template is removed from the above example and replaced
with SomeType, suddenly the Method1 method becomes visible in c# scope.



Kind regards,

Peter.
 
A

A n g l e r

It seems also that declaring the all methods within the base class as
virtual helps. Suddenly they are visible in c# scope, though it is still
not clear to me, why and what happens here. Cannot see the reason to
keep all methods declared as virtual.
 
A

A n g l e r

It seems also that declaring the all methods within the base class as
virtual helps. Suddenly they are visible in c# scope, though it is
still not clear to me, why and what happens here. Cannot see the
reason to keep all methods declared as virtual.

Hmm. Is that such a difficult question for the professionals here or
just scarcely self-explanatory question posed by me? :)


Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top