www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - RE: enum question

<html><body><span style=3D"font-family:Verdana; color:#000; font-size:10pt;=
"><div><br>Awesome... it works!</div><div><br></div><div>-Eric<br></div>=0A=
<blockquote id=3D"replyBlockquote" webmail=3D"1" style=3D"border-left: 2px =
solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:blac=
k; font-family:verdana;">=0A<div id=3D"wmQuoteWrapper">=0A-------- Original=
 Message --------<br>=0ASubject: Re: enum question<br>=0AFrom: Ali =C3=87eh=
reli &lt;<a href=3D"mailto:acehreli yahoo.com">acehreli yahoo.com</a>&gt;<b=
r>=0ADate: Tue, March 18, 2014 3:51 pm<br>=0ATo: <a href=3D"mailto:digitalm=
ars-d-learn puremagic.com">digitalmars-d-learn puremagic.com</a><br>=0A<br>=
=0AOn 03/18/2014 01:40 PM, Eric wrote:<br>=0A<br>=0A &gt; Apparently you ca=
n't pass an enum as a reference,<br>=0A<br>=0AIt is possible as seen in the=
 following code.<br>=0A<br>=0A &gt; I have read on this forum that someday =
enums may be able to be<br>=0A &gt; made with class elements.<br>=0A<br>=0A=
Someday is today! :)<br>=0A<br>=0Aclass C<br>=0A{<br>=0A     int i;<br>=0A<=
br>=0A     this(int i)<br>=0A     {<br>=0A         this.i =3D i;<br>=0A    =
 }<br>=0A}<br>=0A<br>=0Aenum E : C<br>=0A{<br>=0A     one =3D new C(1),<br>=
=0A     two =3D new C(2)<br>=0A}<br>=0A<br>=0Avoid foo(ref E e)<br>=0A{<br>=
=0A     e =3D E.two;<br>=0A}<br>=0A<br>=0Avoid main()<br>=0A{<br>=0A     au=
to e =3D E.one;<br>=0A     foo(e);<br>=0A     assert(e =3D=3D E.two);<br>=
=0A}<br>=0A<br>=0AAli<br>=0A<br>=0A=0A</div>=0A</blockquote></span></body><=
/html>
Mar 18 2014