dereferencing null

deadalnix deadalnix at gmail.com
Fri Mar 2 05:01:45 PST 2012


Le 02/03/2012 11:56, Jacob Carlborg a écrit :
>>
>> False.
>>
>> -----------------------
>> import std.stdio;
>>
>> class Foo
>> {
>> final void bar()
>> {
>> writeln("I'm null!");
>> }
>> }
>>
>> void main()
>> {
>> Foo foo;
>> foo.bar();
>> }
>> -----------------------
>>
>> % dmd test.d -O -release -inline
>> % ./test
>> I'm null!
>> %
>>
>> -----------------------
>>
>> You only get an error if there is a memory access involved (vtable,
>> member data etc.)
>>
>
> I never thought about that.
>

This is a common C++ interview question.


More information about the Digitalmars-d mailing list