clear initializing constructor
Wyverex
wyverex.cypher at gmail.com
Mon Aug 4 11:52:03 PDT 2008
Saaa wrote:
> How do you do something like this?
>
> class Fruit
> {
>
> protected struct _Eigen
> {
> byte color = GREEN;
> bool rotten = false;
> }
> private _Eigen eigen;
>
> this(...)
> {
> // ?
> }
>
> }
>
> apple=new Fruit(color=RED,rotten=false);
> apple2=new Fruit(rotten=true);
> apple3=new Fruit(pit=false); //pit=ignored
>
>
>
class Fruit
{
protected struct _Eigen
{
byte color = GREEN;
bool rotten = false;
}
private _Eigen eigen;
this()
{
}
this(bool rotten, byte color)
{
eigen.rotten = rotten;
eigen.color = color;
}
}
auto apple = new Fruit( false, RED );
auto normal = new Fruit();
More information about the Digitalmars-d-learn
mailing list