struct aliases

Kenny B funisher at gmail.com
Wed Nov 14 12:18:34 PST 2007


Kenny B wrote:
> Ok, I have reduced my code to a simple example... This is what I have:
> 
> class MyClass {
> 	struct Data {
> 		int val1;
> 		int val2;
> 	}
> 	
> 	Data data;
> 	void one_function() {
> 		// stuff
> 	}
> }
> 
> MyClass c = new MyClass;
> // I want to say this:
> c.val1 = 5;
> 
> // not this:
> c.data.val1 = 5;
> 
> ---------------
> 
> I tried to alias the data.val1 val1 -- but it doesn't work. I know this
> works though...
> 
> int val1;
> alias val1 val2;
> 
> val2 = 5;
> assert(val1 == val2);
> 
> How can I do that with the structs?
> 
> I'm using gdc 0.24 on x86_64
> 
> Thanks in advance,
> Kenny

Ugh, thunderbird told me that there was a failure trying to copy the
message to my sentbox, so it wanted to know if I wanted to send the
message again. Sorry for the dup.


More information about the Digitalmars-d-learn mailing list