Only one member of a set of overloaded functions may be published because the RTTI generated for procedures only contains the name.
(*$M+*)
(*$APPTYPE CONSOLE*)
program Produce;
type
Base = class
published
procedure p1(a : integer); overload;
procedure p1(a : boolean); overload;
end;
Extended = class (Base)
procedure e1(a : integer); overload;
procedure e1(a : boolean); overload;
end;
procedure Base.p1(a : integer);
begin
end;
procedure Base.p1(a : boolean);
begin
end;
procedure Extended.e1(a : integer);
begin
end;
procedure Extended.e1(a : boolean);
begin
end;
end.
In the example shown here, both overloaded p1 functions are contained in a published section, which is not allowed.
Further, since the $M+ state is used, the Extended class starts with published visibility, thus the error will also appear for this class also.
(*$M+*)
(*$APPTYPE CONSOLE*)
program Solve;
type
Base = class
public
procedure p1(a : integer); overload;
published
procedure p1(a : boolean); overload;
end;
Extended = class (Base)
public
procedure e1(a : integer); overload;
procedure e1(a : boolean); overload;
end;
procedure Base.p1(a : integer);
begin
end;
procedure Base.p1(a : boolean);
begin
end;
procedure Extended.e1(a : integer);
begin
end;
procedure Extended.e1(a : boolean);
begin
end;
end.
The solution here is to ensure that no more than one member of a set of overloaded function appears in a published section. The easiest way to achieve this is to change the visibility to public, protected or private; whichever is most appropriate.
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
|
What do you think about this topic? Send feedback!
|