我怎么能继承遗产? [英] how can I forbit inheritance?
本文介绍了我怎么能继承遗产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的图书馆,我有班级的成员,这些成员不是虚拟的,我想要
来为这些成员继续继承。
这可能吗?
类似于最终的东西java中的关键字。
A类{
无效成员();
}
类B:公开A {
void member(); //我想要一个致命的编译错误
}
In my library, I have classes''s members which are not virtual and I want
to forbit inheritance for these members.
Is this possible?
Something like "final" keyword in java.
class A {
void member();
}
class B : public A {
void member(); // I want a fatal compile error here
}
推荐答案
Chameleon写道:
Chameleon wrote:
在我的库中,我有类的成员不是虚拟的,我想要
来为这些成员进行forbit继承。 br />
这可能吗?
类似于最终的东西java中的关键字。
A类{
无效成员();
}
B级:公共A {
void member(); //我想要一个致命的编译错误
}
In my library, I have classes''s members which are not virtual and I want
to forbit inheritance for these members.
Is this possible?
Something like "final" keyword in java.
class A {
void member();
}
class B : public A {
void member(); // I want a fatal compile error here
}
查看常见问题。
check FAQ.
Chameleon写道:
Chameleon wrote:
在我的图书馆,我有班级的成员不是虚拟的我想要
来为这些成员继续继承。
这可能吗?
像最终这样的东西java中的关键字。
A类{
无效成员();
}
B级:公共A {
void member(); //我想要一个致命的编译错误
}
In my library, I have classes''s members which are not virtual and I want
to forbit inheritance for these members.
Is this possible?
Something like "final" keyword in java.
class A {
void member();
}
class B : public A {
void member(); // I want a fatal compile error here
}
为什么?
Why ?
不,你不能用C ++做。也许对其他
开发者发表评论。
ps:为什么有些人如此无益?
Chameleon写道:
No you can''t do it in C++. Perhaps leave a comment for other
developers.
ps: Why are some people so unhelpful?
Chameleon wrote:
在我的图书馆,我有班级的成员,这些成员不是虚拟的,我想要
来为这些成员进行forbit继承。
这可能吗?
类似于最终的东西java中的关键字。
A类{
无效成员();
}
B级:公共A {
void member(); //我想要一个致命的编译错误
}
In my library, I have classes''s members which are not virtual and I want
to forbit inheritance for these members.
Is this possible?
Something like "final" keyword in java.
class A {
void member();
}
class B : public A {
void member(); // I want a fatal compile error here
}
这篇关于我怎么能继承遗产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文