var 
   ff:TIniFile;
begin
   if Assigned(ff) then
     ShowMessage('Fuck');
   else
     ShowMessage('Fool');
end;代码输出是什么?没有实例化的类变量用Assigned函数会返回True吗?谢谢!

解决方案 »

  1.   

    ShowMessage('Fuck');后面应该没有分号,呵呵!
      

  2.   

    帮助中这样写到:
     Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.
     
    因为程序中多个地方要到一个变量,而使用这个变量的时候并不知道它是否被实例化,所以要判断,但是用Assigned好像在这里不能达到我的预期,怎么办哦?
      

  3.   

    在Form的OnCreate里给ff个初值, ff := nil; 之后用Assigned判断应该就可以了。
      

  4.   

    你的代码回返回编译错误,嘿嘿.
    ';' not allowed before 'ELSE'
      

  5.   

    楼上的说得好,多谢!能不能说一下为什么申明了变量以后用Assigned函数得出的值是True呢?