Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2007

Tip: Looking for answers? Try searching our database.

Inheritance in managed c++.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
A n g l e r - 25 Apr 2007 12:39 GMT
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 n g l e r - 25 Apr 2007 13:41 GMT
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.

> Hello everybody. I've got a bizarre problem concerning inheritance of
> the managed c++ code when using templates. Consider the following
[quoted text clipped - 23 lines]
> replaced with SomeType, suddenly the Method1 method becomes visible in
> c# scope.
A n g l e r - 30 Apr 2007 12:30 GMT
> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.