type
 TMyClass = class
 procedure One;virtual;
  end; type
 TNewClass = class(TMyClass)
  procedure One;virtual;
  end;
//TmyClass中的one方法,是抽象的方法,你并没有实现它,
这话是什么意思,什么是是抽象的方法,什么是没有实现它,//

解决方案 »

  1.   

    基类没实现啊!TMYCLASS里!
    如果只是声明一下要用纯虚函数!
      

  2.   

    是的。。在基类中是不能直接实现虚函数的。
    在基类中使用virtual,在派生类中使用override。如果忘记了这一点的话,会导致两个后果:
    1.编译程序的时候会得到一个“Method ‘XXX’hides the virtual method of base type ‘XXX’”(尽管程序还可以运行
    2.多态机制将无法正常工作。
    type  TAnimal=class
        procedure Voice;virtual;
      end;  TDog=class(TAnimal)
         procedure Voice;virtual;
      end;implementationprocedure TAnimal.Voice;
    begin
     ShowMessage(‘Animal Voice’);
    end;
    procedure TDog.Voice;
    begin
      ShowMessage(‘Dog Voice’);
    end;
    procedure TForm1.FormCreate(Sender:TObject);
    var
      a : TAnimal;
    begin
      a := TAnimal.Create;
      a.Voice;
      a.Free;
      a := TDog.Create;
      a.Voice;
      a.Free;
    end;
    运行这个程序的话,你会得到两个‘Animal Voice’。只要将声明中第二个virtual 改为override,你就能得到正确的结果:一个’Animal Voice’ 和一个’Dog Voice’
    这个在Mastering Delphi中有详细的说明。。