Private nested class instance accessed via outer class public interface

Murloc justanotheraccount3212334 at proton.me
Fri Jun 16 07:47:50 UTC 2023


And since classes can be declared locally inside methods, you can 
also do something similar this way:

```d
import std.stdio;
import std.conv;

Object getB() {
     class B {
		private int field = 30;
         override string toString() => to!string(field);
	}
     return cast(Object)new B();
}

void main() {
     auto b = getB();
     writeln(b); // 30
}
```


More information about the Digitalmars-d-learn mailing list