如下代码:
module a;
class Foo
{
private:
int _c;
}
import b;
void handle(Bar child)
{
child._c += child.c;
}
//---------
module b;
import a;
class Bar : Foo
{
public:
int c;
this(int c)
{
this.c = c;
}
}
//---------
module main;
import a;
import b;
void main()
{
auto bar = new Bar(30);
handle(bar);
}
应该允许在a
模块中,
void handle(Bar child)
{
child._c += child.c;//应允许可访问_c
}
毕竟,你是标榜自己模块级封装
.