Re: [fpc-pascal] Polymorphism question
I made a typo which I didn't notice, thanks for the replies. > On Fri, 03 Mar 2006 04:52:36 -0300, <[EMAIL PROTECTED]> wrote: > >> (I sent this mail yesterday but somehow it didn't get trough, therefore >> a >> new try) >> >> I would like to declare a polymorph class. The class has several >> properties and it's the read and write specifiers that I want to be >> virtual abstract. So derived classes override the read and write >> specifiers. The problem however is that I get an EAbstractError. The >> property is still considered to be abstract according to the compiler. >> So >> what did I wrong? I have added an example below. >> Is it perhaps not allowed to use this construct? What would then be the >> best way? >> Darius >> >> <> >> >> unit MyTest; >> >> {$mode objfpc}{$H+} >> >> interface >> >> uses >> Classes, ComCtrls, SysUtils; >> >> type >> TCustomClass = class >> private >> //virtual mehods >> function GetMyProperty: string; virtual; abstract; >> procedure SetMyProperty(Value: string); virtual; abstract; >> published >> >> property MyProperty: string Read GetMyProperty Write SetMyProperty; >> end; >> >> TMyClass = class(TCustomClass) >> private >> FMyProperty: string; >> >> function GetMyProperty: string; overload; >> procedure SetMyProperty(Value: string); overload; >> published >> property MyProperty; >> end; >> >> implementation >> >> function TMyClass .GetMyProperty: string; >> begin >> Result := FMyProperty; >> end; >> >> procedure TMyClass .SetMyProperty(Value: string); >> begin >> if Value = FMyProperty then >> exit; >> >> FMyProperty := Value; >> end; >> end. >> >> >> >> ___ >> fpc-pascal maillist - fpc-pascal@lists.freepascal.org >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> > > Try override instead of overload > > -- > Rodrigo Palhano > - > Equipe SpeedCASE > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Polymorphism question
On Fri, 03 Mar 2006 04:52:36 -0300, <[EMAIL PROTECTED]> wrote: (I sent this mail yesterday but somehow it didn't get trough, therefore a new try) I would like to declare a polymorph class. The class has several properties and it's the read and write specifiers that I want to be virtual abstract. So derived classes override the read and write specifiers. The problem however is that I get an EAbstractError. The property is still considered to be abstract according to the compiler. So what did I wrong? I have added an example below. Is it perhaps not allowed to use this construct? What would then be the best way? Darius <> unit MyTest; {$mode objfpc}{$H+} interface uses Classes, ComCtrls, SysUtils; type TCustomClass = class private //virtual mehods function GetMyProperty: string; virtual; abstract; procedure SetMyProperty(Value: string); virtual; abstract; published property MyProperty: string Read GetMyProperty Write SetMyProperty; end; TMyClass = class(TCustomClass) private FMyProperty: string; function GetMyProperty: string; overload; procedure SetMyProperty(Value: string); overload; published property MyProperty; end; implementation function TMyClass .GetMyProperty: string; begin Result := FMyProperty; end; procedure TMyClass .SetMyProperty(Value: string); begin if Value = FMyProperty then exit; FMyProperty := Value; end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal Try override instead of overload -- Rodrigo Palhano - Equipe SpeedCASE ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] polymorphism question
I would like to declare a polymorph class. The class has several properties and it's the read and write specifiers that I want to be virtual abstract. So derived classes override the read and write specifiers. The problem however is that I get an EAbstractError. The property is still considered to be abstract according to the compiler. So what did I wrong? I have added an example below. Is it perhaps not allowed to use this construct? What would then be the best way? Darius <> unit MyTest; {$mode objfpc}{$H+} interface uses Classes, ComCtrls, SysUtils; type TCustomClass = class private //virtual mehods function GetMyProperty: string; virtual; abstract; procedure SetMyProperty(Value: string); virtual; abstract; published property MyProperty: string Read GetMyProperty Write SetMyProperty; end; TMyClass = class(TCustomClass) private FMyProperty: string; function GetMyProperty: string; overload; procedure SetMyProperty(Value: string); overload; published property MyProperty; end; implementation function TMyClass .GetMyProperty: string;begin Result := FMyProperty;end; procedure TMyClass .SetMyProperty(Value: string);begin if Value = FMyProperty then exit; FMyProperty := Value;end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Polymorphism question
i'm new so grain of salt ... On 3/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > function GetMyProperty: string; overload; > procedure SetMyProperty(Value: string); overload; should these be 'override' rather than 'overload' ? -- X-SA user ? 0.4 is out ! http://x-plane.dsrts.com http://games.groups.yahoo.com/group/x-plane-foo/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Polymorphism question
(I sent this mail yesterday but somehow it didn't get trough, therefore a new try) I would like to declare a polymorph class. The class has several properties and it's the read and write specifiers that I want to be virtual abstract. So derived classes override the read and write specifiers. The problem however is that I get an EAbstractError. The property is still considered to be abstract according to the compiler. So what did I wrong? I have added an example below. Is it perhaps not allowed to use this construct? What would then be the best way? Darius <> unit MyTest; {$mode objfpc}{$H+} interface uses Classes, ComCtrls, SysUtils; type TCustomClass = class private //virtual mehods function GetMyProperty: string; virtual; abstract; procedure SetMyProperty(Value: string); virtual; abstract; published property MyProperty: string Read GetMyProperty Write SetMyProperty; end; TMyClass = class(TCustomClass) private FMyProperty: string; function GetMyProperty: string; overload; procedure SetMyProperty(Value: string); overload; published property MyProperty; end; implementation function TMyClass .GetMyProperty: string; begin Result := FMyProperty; end; procedure TMyClass .SetMyProperty(Value: string); begin if Value = FMyProperty then exit; FMyProperty := Value; end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal