托管代码中MI的替代方案??? [英] Alternatives to MI in managed code???

查看:68
本文介绍了托管代码中MI的替代方案???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于托管代码(C ++ / C#/等)不支持多重继承,

任何人都有合适的解决方法吗?对我来说,这是.NET子系统的严重*限制。


我知道*接口*,但它们适用于类的* USER *,而不是

* IMPLEMENTOR *。我也知道在一个类中添加多个类,然后创建包装器(更多的是HAS-A实现而不是IS-A),但是那是

繁琐又多为班级用户更多,并且不支持多态。


这是一个例子:


假设我有一个没有接口的非平凡类(它纯粹是一个

功能组件)。 *没有办法*在没有更改基类本身的情况下将界面(ala表格)添加到

该组件。


-

Bret Pehrson

mailto:br ** @ infowest.com

NOSPAM - 在所有电子邮件通信中包含此密钥<< 38952rglkwdsl>>

Since managed code (C++/C#/etc.) doesn''t support multiple inheritance, does
anyone have a suitable work-around? To me, this is a *serious* limitation of
the .NET subsystem.

I''m aware of *interfaces*, but they are for the *USER* of the class, not the
*IMPLEMENTOR*. I''m also aware of adding multiple classes to a class and then
creating wrappers (more of a HAS-A implementation than IS-A), but that is
tedious and again is more for the class user and doesn''t support polymorphism.

Here is an example:

Suppose I have a non-trivial class that has no interface (it is purely a
functional component). There is *no way* to add an interface (ala forms) to
that component without changing the base class itself.

--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>

推荐答案

Bret Pehrson写道:
Bret Pehrson wrote:
假设我有一个没有界面的非平凡类(它纯粹是一个功能组件。 *没有办法*在不更改基础类本身的情况下向该组件添加
接口(ala表单)。
Suppose I have a non-trivial class that has no interface (it is
purely a functional component). There is *no way* to add an
interface (ala forms) to that component without changing the base
class itself.




为什么不继承自System.Windows.Form?


-

有10种人。那些懂二元的人和那些没有b $ b的人。

http://code.acadx.com

(拉针回复)



Why not inherit from System.Windows.Form?

--
There are 10 kinds of people. Those who understand binary and those who
don''t.

http://code.acadx.com
(Pull the pin to reply)


>为什么不继承System.Windows.Form?


正如我所说:
> Why not inherit from System.Windows.Form?

As I said:
有* no方式*在不更改基础类本身的情况下向该组件添加
接口(ala表单)。
There is *no way* to add an
interface (ala forms) to that component without changing the base
class itself.



我无法访问基础修改它的继承类。

Frank Oquendo写道:
Bret Pehrson写道:


I don''t have access to the base class to modify its inheritance.
Frank Oquendo wrote:
Bret Pehrson wrote:

假设我有一个没有界面的非平凡类(它纯粹是一个功能组件)。 *没有办法*在不更改基本类本身的情况下向该组件添加
接口(ala表单)。
Suppose I have a non-trivial class that has no interface (it is
purely a functional component). There is *no way* to add an
interface (ala forms) to that component without changing the base
class itself.



为什么不从System继承。 Windows.Form?

-
有10种人。那些了解二元和那些不知道的人。

http://code.acadx.com
(拉针回复)



Why not inherit from System.Windows.Form?

--
There are 10 kinds of people. Those who understand binary and those who
don''t.

http://code.acadx.com
(Pull the pin to reply)




-

Bret Pehrson

mailto:br ** @ infowest.com

NOSPAM - 在所有电子邮件中包含此密钥<< 38952rglkwdsl>>



--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>


Bret Pehrson写道:
Bret Pehrson wrote:
我无权访问基类来修改其继承。
I don''t have access to the base class to modify its inheritance.




如果您可以访问派生类,则从中派生一个新类和

System.Windows.Form。


-

有10种人。那些懂二元的人和那些没有b $ b的人。

http://code.acadx.com

(拉针回复)



If you have access to the derived class, derive a new class from it and
System.Windows.Form.

--
There are 10 kinds of people. Those who understand binary and those who
don''t.

http://code.acadx.com
(Pull the pin to reply)


这篇关于托管代码中MI的替代方案???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆