enum for beginners

Johannes Totz johannes at jo-t.de
Tue Nov 15 15:33:56 PST 2011


On 15/11/2011 22:56, bearophile wrote:
> 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?

struct works, thanks!
No need for class.


More information about the Digitalmars-d-learn mailing list