抽象密封类

发布于 2024-09-17 21:21:14 字数 108 浏览 3 评论 0原文

只是一个关于 c++/cli 的小问题。 抽象类具有由派生类实现的抽象方法, 密封类不允许继承。

那么为什么我们在 .NET 基类库中将一些类定义为抽象密封,并且您可以找到很多..??!

Just a small question about c++/cli.
Abstract classes have abstract methods to be implemented by derived classes,
sealed classes dont allow inheritance.

So why we have some classes in .NET base class library defined as abstract sealed, and you can find plenty .. ??!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海似她心 2024-09-24 21:21:14

相当于C#语言中的“静态类”。用于编写几乎所有 BCL 类的语言。所有方法都必须是静态的。将其声明为抽象和密封可以防止任何人从该类派生并创建它的实例。

类方法与 C 和 C++ 语言中的自由函数完全相同。 CLR 不支持的东西。

It is equivalent to "static class" in the C# language. The language that was used to write almost all of the BCL classes. All the methods must be static. Declaring it abstract and sealed prevents anybody from deriving from the class and creating an instance of it.

The class methods are the exact equivalent of free functions in the C and C++ language. Something the CLR does not support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文