Returning references to const data from const methods

Leonard Dahlmann leo.dahlmann at gmail.com
Mon Jun 18 23:33:31 PDT 2007


How could I do the following?

I'm getting this error message:
test.d(15): Error: c.gimme can only be called on a mutable object

<code>
class Foo
{
	uint x;

	const (const(uint)*) gimme()
	{
		return &x;
	}
}

void main()
{
	const(Foo) c = new Foo;

	const(uint)* x = c.gimme(); // line 15
}
</code>


More information about the Digitalmars-d-learn mailing list