- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
刚刚看到一个教程说:
Class Dog
{
private string Name;
}
Class SuperDog:Dog
{
private string Mood;
}
然后有一个 UML 显示 SuperDog 也将继承 Name。我试过了,但对我来说似乎只有公共(public)成员是继承的。至少我无法访问 Name,除非它被声明为公共(public)。
最佳答案
A derived class has access to the public, protected, internal, and protected internal members of a base class. Even though a derived class inherits the private members of a base class, it cannot access those members. However, all those private members are still present in the derived class and can do the same work they would do in the base class itself. For example, suppose that a protected base class method accesses a private field. That field has to be present in the derived class in order for the inherited base class method to work properly.
发件人:http://msdn.microsoft.com/en-us/library/ms173149.aspx
因此,从技术上讲,是的,但实际上不是。
关于c# - 私有(private)成员是否在 C# 中继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2950820/
我是一名优秀的程序员,十分优秀!