Assigned()是干什么用得???比如我想释放一个对象实例,我可以直接用她得Free.
为什么要用
if Assigned(MyClass) then MyClass.Free在她得Free中不是有判断她是不是nil,在destroy得吗??
为什么还在外面用Assigned来判断呢????

解决方案 »

  1.   

    assigned用来判断对像是否已经创建
      

  2.   

    g1120(代码最优化-§雪是冷的,人是暖的§)的回答太精辟了
      assigned用来判断对像是否已经创建
      

  3.   

    DELPHI帮助里解释的很清楚,要学会看帮助!DescriptionUse Assigned to determine whether the pointer or procedure referenced by P is nil. P must be a variable reference of a pointer or procedural type. Assigned(P) corresponds to the test P<> nil for a pointer variable, and @P <> nil for a procedural variable.Assigned returns False if P is nil, True otherwise.Note: 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.因为一个对象实例没创建之前,该对象指针指向nil
      

  4.   

    指针变量被赋值即对象被创建
    form1是啥?form1就是指针,我个人是这样理解的
      

  5.   

    呵呵,wangsin朋友不同意我的看法吗?其实如上面的朋友所说Form1就是一个对象指针变量!当你声明了一个TObject(或者TObject的派生类)类型的变量的时候,你便获得了一个对象指针!它指向内存中的对象空间,对象空间的头4个字节是指向该对象类的虚方法地址表(VMT–Vritual Method Table)。接下来就是对象成员数据,并按从派生该对象的祖先类的成员到该对象类的成员,和每一级类中成员的定义顺序存储!如果按照严格的语法规则,正确的访问方式应该是MyObject^.XXXX,当然用Object Pascal编译器只能是MyObject.XXXX,但不表示MyObject就不是指针!如果有空学学BCB,这类问题更好理解!
      

  6.   

    经常看到ehom(?!) 的贴子,是个高手!!