Re: Alias variable from another class

2016-12-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 19:13:24 UTC, Begah wrote: Any ideas? Closest you can get is wrapping it in a property. If you need to do this often you may be able to generate them, check the recent "Getters/Setters generator" thread in Announce for some inspiration.

Re: Alias variable from another class

2016-12-14 Thread ketmar via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 19:13:24 UTC, Begah wrote: Any ideas? you can't.

Re: Alias variable from another class

2016-12-13 Thread Ali via Digitalmars-d-learn
I guess it's because you're accessing a member of _1 from inside a scope of _2 where nothing has been constructed yet? Someone more familiar with D would probably have a better answer on this part. I'm quite new :) But a work around would be class _2 { _1 instance;

Alias variable from another class

2016-12-13 Thread Begah via Digitalmars-d-learn
I made a little program to illustrate my confusion : import std.stdio; class _1 { int i; this(int n) { i = n; } } class _2 { _1 instance; alias twelve = instance.i; this() {