enum for beginners

bearophile bearophileHUGS at lycos.com
Tue Nov 15 14:56:10 PST 2011


Johannes Totz:

> class EnumType
> {
> 	int	x;
> 	alias x this;
> 
> 	this(int i)
> 	{
> 		x = i;
> 	}
> 
> 	void opCall(int i)
> 	{
> 	}
> }
> 
> enum X : EnumType
> {
> 	a = EnumType(1),
> 	b = 2
> }
> 
> 
> Errors range are always variations of
> 
> main.d(16): Error: function main.EnumType.opCall need 'this' to access 
> member opCall

The error message suggests you to use a static opCall.
And are you sure you want a class instead of a struct?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list