Question about RAII.

Peter C. Chapin pchapin at sover.net
Wed Jul 5 03:36:36 PDT 2006


Walter Bright <newshound at digitalmars.com> wrote in
news:e8f9b7$17u2$1 at digitaldaemon.com: 

> You can make the D version behave like the C++ one as follows:
> 
> Example g()
> {
>    auto Example object1 = new Example;
>    auto Example object2 = new Example;
>    Example object3;
> 
>    if (f()) {
>      object3 = new Example(object1);
>    }
>    else {
>      object3 = new Example(object2);
>    }
>    return object3;
> }

I see what you are saying. Thanks, that is helpful.

Peter



More information about the Digitalmars-d mailing list