纯粹的自我功能 [英] pure virttual function
问题描述
任何人都可以解释为什么定义为纯虚拟功能
允许
?
>
sks写道:
任何人都可以解释为什么定义为纯虚函数
允许
?
可能是你问为什么不允许这样做。
见常见问题。在那里可以更好地解释。
http:/ /www.parashift.com/c++-faq-lite/
- Murali Krishna
< BLOCKQUOTE>" SKS" < es ****** @ gmail.com写信息
新闻:11 ********************** @ l70g2000cwa .googlegr oups.com ...
>
任何人都可以解释为什么定义一个纯虚函数
允许
?
是的,Herb Sutter可以:
http://www.gotw.ca/gotw/031.htm
希望这会有所帮助:)
Stu
Murali Krishna写道:
sks写道:
< blockquote class =post_quotes>
任何人都可以解释为什么定义为纯虚函数
允许
?
可能是你问为什么不允许这样做。
见常见问题。在那里可以更好地解释。
http:/ /www.parashift.com/c++-faq-lite/
- Murali Krishna
否,我的问题是为什么在
基类中允许定义纯虚拟,例如这样
类ABC
{
public:
virtual f1()= 0;
{
std :: cout<<"嗨;
}
}
您可以派生这个类并将自己的实现提供给f1()
但是在基类中允许定义有什么用?
Hi ,
could anyone explain me why definition to a pure virtual function
is allowed ?
sks wrote:Hi ,
could anyone explain me why definition to a pure virtual function
is allowed ?May be you are asking why it is not allowed.
See FAQ. it is better explained there.
http://www.parashift.com/c++-faq-lite/
-- Murali Krishna
"sks" <es******@gmail.comwrote in message
news:11**********************@l70g2000cwa.googlegr oups.com...>
Hi ,
could anyone explain me why definition to a pure virtual function
is allowed ?Yes, Herb Sutter can:
http://www.gotw.ca/gotw/031.htm
Hope this helps :)
Stu
Murali Krishna wrote:sks wrote:Hi ,
could anyone explain me why definition to a pure virtual function
is allowed ?
May be you are asking why it is not allowed.
See FAQ. it is better explained there.
http://www.parashift.com/c++-faq-lite/
-- Murali KrishnaNo , My question was why defintion to pure virtual is allowed in the
base class eg this way
class ABC
{
public:
virtual f1()=0;
{
std::cout<<"Hi";
}
}
You may derive this class and provide your own implementation to f1()
but what is the use in allowing the definition in base class?
这篇关于纯粹的自我功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!