Alias variable from another class

Ali via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 13 13:34:01 PST 2016


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;
	
	  auto twelve() @property {
               return instance.i;
           }
	
	  this() {
		  instance = new _1(12);
	  }
   }




More information about the Digitalmars-d-learn mailing list