我的班级可以判断其中一个虚拟成员是否超载? [英] Can my class tell if one of its virtual members is overloaded?

查看:40
本文介绍了我的班级可以判断其中一个虚拟成员是否超载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的课程:


class foo

{

protected virtual void MyMember()

{

}

}


当这个类是任意数量的衍生物的基础时,

有没有办法判断虚拟成员函数

是否在任何派生类中重载,包括具体的

实例类?



-

Tony M.

解决方案

你确定你想知道重载吗?我想你的意思是覆盖。


Ab。


" Tony Maresca"写道:

我的课程:

class foo
{
protected virtual void MyMember()
{
}
}

当这个类是一个有许多衍生物的基础时,有一种方法可以判断虚拟成员函数是否过载在任何派生类中,包括具体的实例类?

-
Tony M



对不起,是的,我的意思是覆盖,而不是超载。


-

Tony M.

" Abubakar" < AB- ****** @ discussions.microsoft.com>在留言新闻中写道:E4 ********************************** @ microsof t.com ...

你确定你想知道重载吗?我想你的意思是覆盖。

Ab。

Tony Maresca写道:

我的课程:

class foo
{
protected virtual void MyMember()
{
}
}

当这个类是一个有许多衍生物的基础时,有没有办法告诉它是否虚拟成员函数
在任何派生类中重载,包括具体的实例类?


-
Tony M


Tony Maresca写道:

当这个类是一个有许多衍生物的基础时,
有没有办法告诉它是否虚拟成员函数
在任何派生类中重载,包括具体的实例类?




当然不是你要求的通用方式,仅仅因为基础

类对存在的派生类一无所知。

怎么样?衍生的类可以到处都是,可能在另一个

汇编中。


我想可以用

反射,你已经知道正在调用特定的

重写方法(或者你使用的是这种方法,所以

说话),但这听起来并不像你要问的那样。


你想做什么?

Oliver Sturm

-

omnibus ex nihibo ducendis sufficit unum

插入空格以防止谷歌电子邮件销毁:

MSN oliver @ sturmnet.org Jabber sturm @ amessage.de

ICQ 27142619 http://www.sturmnet。组织/博客


My class:

class foo
{
protected virtual void MyMember()
{
}
}

When this class is a base with any number of derivatives,
is there a way for it to tell if the virtual member function
is overloaded in any derived class, including the concrete
instance class?


--
Tony M.

解决方案

R u sure u wanna know about overloads? I guess u meant "overriden".

Ab.

"Tony Maresca" wrote:

My class:

class foo
{
protected virtual void MyMember()
{
}
}

When this class is a base with any number of derivatives,
is there a way for it to tell if the virtual member function
is overloaded in any derived class, including the concrete
instance class?
--
Tony M



Sorry, yes, I meant override, not overload.

--
Tony M.
"Abubakar" <Ab******@discussions.microsoft.com> wrote in message news:E4**********************************@microsof t.com...

R u sure u wanna know about overloads? I guess u meant "overriden".

Ab.

"Tony Maresca" wrote:

My class:

class foo
{
protected virtual void MyMember()
{
}
}

When this class is a base with any number of derivatives,
is there a way for it to tell if the virtual member function
is overloaded in any derived class, including the concrete
instance class?


--
Tony M


Tony Maresca wrote:

When this class is a base with any number of derivatives,
is there a way for it to tell if the virtual member function
is overloaded in any derived class, including the concrete
instance class?



Certainly not in the generic way you are asking, simply because the base
class doesn''t know anything about derived classes that exist. How would
it? The derived classes could be all over the place, possibly in another
assembly.

I imagine that it might be possible to find something out with
Reflection at the point where you already know that a specific
overridden method is being called (or you are in that method, so to
speak), but that doesn''t sound like what you''re asking.

What are you trying to do?
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog


这篇关于我的班级可以判断其中一个虚拟成员是否超载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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