procedure xxx
  type  //定义这个函数专用的类
   hhh=class
   ...
  end;
var
  ...
begin  //函数开始
  ....
  .....//想这么定义,但报错

解决方案 »

  1.   

    不能这样定义。Borland公司的说明:Class and object cannot be declared local to a procedure. program Produce;  procedure MyProc;
      type
        TMyClass = class
          Field: Integer;
        end;
      begin
      (*...*)
      end;begin
    end.So MyProc tries to declare a class type locally, which is illegal. program Solve;  type
        TMyClass = class
          Field: Integer;
        end;  procedure MyProc;
      begin
      (*...*)
      end;begin
    end.The solution is to move out the declaration of the class or object type to the global scope.
      

  2.   

    没有见过这样定义的,你试一下下面的可以吗?
    在窗体或者UNIT里定义类,然后在这里调用。procedure xxx
     var 
       hhh=T+(类名)   ...
      end;
    var
      ...
    begin    ....
      .....
      

  3.   

    可以在implementation中定义类来“达到”私有类的效果。但不是“真正”的私有。
      

  4.   

    不行,而且也没有发现Borland有增加此功能的意思