473,508 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritance in managed c++.

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.

Apr 25 '07 #1
2 3528
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
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.


Apr 25 '07 #2
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

Apr 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8171
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
30
2677
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
14
12106
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
8
2877
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
22
23319
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
3
41509
by: enchantingdb | last post by:
I have an exam tomorrow that covers the perceived advantages and disadvantages of object oriented programming, in particular polymorphism, inheritance and encapsulation. I know the advantages but...
1
2950
by: vinoraja | last post by:
There are a number of reasons we don't implement Multiple Implementation Inheritance directly. (As you know, we support Multiple Interface Inheritance). However, I should point out that it's...
14
4498
by: karthikbalaguru | last post by:
Hi, What could be the maximum Accepted Layers/Levels of inheritance in a normal C++ program that has private(data),protected(data) and public(data,member functions) ? On what does this depend...
3
2884
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.