Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #16  
Antiguo 05-12-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Daniel,

Cita:
Empezado por ecfisa
...conviene abstenerse de incluir métodos virtuales cuando se usa el antiguo estilo Pascal...trae aparejado problemas que ya han sido reportados en QualityCentral...


Revisa este código:
Código Delphi [-]
 
  program testD2009;
  
  {$APPTYPE CONSOLE}
  
  uses
    SysUtils;
  
  Type
    PObject1 = ^TObject1;
    TObject1 = Object
      FCount     : Integer;
      Constructor Init;
      Procedure Add; virtual; { removing virtual allows the program to run }
      end;
  
  Type
    PObject2   = ^TObject2;
    TObject2   = Object(TObject1)
      Constructor Init;
      end;
  
  Constructor TObject1.Init;
  begin
  { Commenting out this assignment allows the program to run.
    It also runs if Procedure Add; is not Virtual.
    I presume there is some address mismatch resulting in an
    over-write of the VMT }
  FCount := 0;
  Writeln('TDynArray:Init');
  end;
  
  Procedure TObject1.Add;
  begin
  Writeln('Add');
  end;
  
  Constructor TObject2.Init;
  begin
  Inherited Init;
  Writeln('TObject2:Init');
  end;
  
  Var
    Object1 : PObject1;
    Object2 : PObject2;
  begin
    try
      Object1 := New(PObject1,Init);
      Object1^.Add;
  
      Object2 := New(PObject2,Init);
      Object2^.Add;
      readln;
    except
      on E:Exception do
        Writeln(E.Classname, ': ', E.Message);
    end;
  end.
Tomado de : QualityCentral-Using old style Objects in D2009 fails

El código anterior que falla en Delphi 2009 según se indica en QualityCentral, funciona correctamente en Delphi 2010 y Delphi XE6 sobre Windows x32 y Delphi XE7 sobre Windows 10 Technical Preview x32, al parecer el problema reportado solo aplica a Delphi 2009, no obstante para desarrollos formales orientados a objetos se debe usar el tipo Class.

Espero sea útil

Nelson.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Un momento, ¿no sería mejor comenzar con Python 3.x? Al González Python 4 05-04-2011 16:30:43
Liberar un objeto Com marcosl OOP 1 25-10-2007 00:10:19
Liberar el foco de un objeto Velia Varios 4 18-11-2005 01:08:08
Liberar un objeto xerkan Servers 1 28-10-2003 17:29:10


La franja horaria es GMT +2. Ahora son las 15:45:51.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi