null assignment to bit variable

Sean Kelly sean at f4.ca
Tue Aug 15 14:59:21 PDT 2006


Peter Thomassen wrote:
> Sean Kelly schrieb am Dienstag, 15. August 2006 03:34:
>>      bool* test = null;
>>
>>      test = new bool;
> 
> This looks nice ... but how do I read / write the value of test? After
> assigning "new bool", reading it gives a memory address, and writing fails.
> Maybe I should've posted to digitalmars.D.learn :-)

The other suggestion to use an enum is a better one.  To use the bool 
above you have to dereference the pointer:

     if( test !is null && *test )
     {
         // something that requires test to be set and true
     }


Sean



More information about the Digitalmars-d mailing list