为什么虚拟函数是私有的? [英] Why would a virtual function be private?
本文介绍了为什么虚拟函数是私有的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一些代码中发现了这一点:
class Foo {
[...]
private:
virtual void Bar()= 0;
[...]
}
这有什么用吗? / p>
(我试图将一些代码从VS移植到G ++,这引起了我的注意)
解决方案
请参阅这篇Herb Sutter文章,了解为什么要这样做东西。
I just spotted this in some code:
class Foo {
[...]
private:
virtual void Bar() = 0;
[...]
}
Does this have any purpose?
(I am trying to port some code from VS to G++, and this caught my attention)
解决方案
See this Herb Sutter article as to why you'd want to do such a thing.
这篇关于为什么虚拟函数是私有的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文