完成虚拟方法 [英] Finalizing virtual methods
问题描述
大家好,
假设我有一个类(让我们用A类调用A类)。
然后定义一个子类(B),它可能会被某些
其他子类(比方说,C)扩展。因此,A< -B< -C。我想以与最终的方式相同的方式来防止C重新定义虚拟方法。 Java中的方法
无法覆盖..有没有办法在C ++中执行此操作?
Dave。
Hi all,
Suppose that I have a class (let''s call the class A) with a virtual method.
I then define a subclass (B), which could potentially be extended by some
other subclass (say, C). So, A <- B <- C. I want to prevent C from
redefining the virtual method in same manner as how a "final" method in Java
cannot be overridden.. Is there some way to do this in C++?
Dave.
推荐答案
" Dave Rudolf" < NU **************** @ hotmail.com>写道...
"Dave Rudolf" <nu****************@hotmail.com> wrote...
假设我有一个类(让我们称之为A类),使用虚拟的
方法。然后我定义了一个子类(B),它可能会被某些其他子类(比方说,C)扩展。因此,A< -B< -C。我希望以与最终方式相同的方式防止C重新定义虚拟方法。
中的方法无法覆盖Java。有没有办法在C ++中执行此操作?
Suppose that I have a class (let''s call the class A) with a virtual method. I then define a subclass (B), which could potentially be extended by some
other subclass (say, C). So, A <- B <- C. I want to prevent C from
redefining the virtual method in same manner as how a "final" method in Java cannot be overridden.. Is there some way to do this in C++?
否。为什么要这样做?
No. Why would you want to do that?
" Dave Rudolf" < NU **************** @ hotmail.com>在消息中写道
新闻:10 ************* @ corp.supernews.com ...
"Dave Rudolf" <nu****************@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
大家好,
假设我有一个类(让我们称之为A类),使用虚拟的
方法。然后我定义了一个子类(B),它可能会被某些其他子类(比方说,C)扩展。因此,A< -B< -C。我希望以与最终方式相同的方式防止C重新定义虚拟方法。
中的方法无法覆盖Java ..有没有办法在C ++中执行此操作?
Dave。
Hi all,
Suppose that I have a class (let''s call the class A) with a virtual method. I then define a subclass (B), which could potentially be extended by some
other subclass (say, C). So, A <- B <- C. I want to prevent C from
redefining the virtual method in same manner as how a "final" method in Java cannot be overridden.. Is there some way to do this in C++?
Dave.
文档,这是唯一的方法。或者选择另一种语言,也许是从字母J开始的
john
Documentation, its the only way. Or choose another language, perhaps
beginning with the letter J.
john
" Victor Bazarov" <五******** @ comAcast.net>在消息中写道
新闻:TSiXb.302123
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:TSiXb.302123
这篇关于完成虚拟方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!