delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
新人求助关于类的构造和封装问题 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061206195523254.html
为了练习类的构造和封装,自己写了这样一个小程序,设计三个单元unit   Person,unit   ET,unit   Form,可是在写完Person单元的程序再在ET单元引用Person单元时出现了这样一个错误:找不到Person的DCU文件,于是自己尝试编译了Person单元的文件,又出现了这样一个错误:[Error]   Person.pas(17):   Unsatisfied   forward   or   external   declaration:   'TPerson.Create'。不知道该怎么改,麻烦大家看看,现在贴出Person单元的程序:  
  unit   Person;  
   
  interface  
      uses   classes,dialogs;  
  type  
      TPerson   =class  
      private  
          blood:char;  
      protected  
          DNA:string;  
      public  
          maName:string;  
          high:integer;  
      procedure   setNNA(a:   string);  
      function   getBlood:string;  
      function   getDNA:string;  
      constructor   Create;  
  end;  
  implementation  
      procedure   TPerson.setNNA(a:string);  
        begin  
            DNA:=a;  
        end;  
      function   TPerson.getDNA:string;  
          begin  
              result:=DNA;  
          end;  
      function   TPerson.getBlood:string;  
          begin  
              result:=blood;  
          end;  
  var  
          Color1:TPerson;  
  begin  
      Color1:=TPerson.Create;  
      Color1.DNA:='Color1   的   DNA   =AA913';  
      Color1.blood:='A';  
      ShowMessage('Color1.DNA   ='+Color1.DNA+#13  
                              +'Color1.blood   ='+Color1.blood);  
      Color1.Free;  
  end.  
 

implementation  
   
  constructor   TPerson.Create;  
  begin  
      inherited;  
      //你的代码  
  end;

posted on 2009-04-22 10:45 delphi2007 阅读(113) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。