D2 Pointer confusion

A Bothe info at alexanderbothe.com
Sun Aug 30 12:45:01 PDT 2009


Hey guys,
I got a problem with the following code:

void main()
{
	struct SomeStruct
	{
		int aa;
	}
	
	class SomeClass
	{
		int a;
		
		SomeStruct foo()
		{
			SomeStruct m;
			m.aa=a;
			return m;
		}
	}
	
	SomeClass inst=new SomeClass();
	inst.foo.aa=20;
	
	assert(inst.a==20);
}


How can I make D set the member variable 'a' of SomeClass via this construction to another value?
And what's with using "ref SomeStruct foo() {}"?

Thanks in advance!

------------------------------------------------------------------------------
PS: Check out my D-IDE at http://www.alexanderbothe.com/?id=27


More information about the Digitalmars-d-learn mailing list