Florian Klaempfl ha scritto:
Skybuck Flying schrieb:
One drawback of objects already discovered:

Objects cannot have the same field identifiers.

Indeed, especially if you want to win an obfuscation contest.

ok, this is true for object type, but it should not be extended to class
types. Look at this example taken from Delphi Help:

type
  TAncestor = class
    Value: Integer;
  end;

  TDescendant = class(TAncestor)
    Value: string;  // hides the inherited Value field
  end;

var
  MyObject: TAncestor;

begin
  MyObject := TDescendant.Create;
  // MyObject.Value := 'Hello!';  // error
  TDescendant(MyObject).Value := 'Hello!';  // works!
end;

it compiles correctly in Delphi (5 and 7) but FPC (v2.2.0 - compiled with Params Values=" -S2cdgi -OG1 -gl -WG -vewnhi") still says
that there is a duplicate identifier "Value"...

am I correct?

--
tiziano
______________________________________
http://digilander.libero.it/tizzziano/
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to