Dennis
2018-08-15 08:59:35 UTC
I was trying to use a generic class TDictionary<T> with type T. This
class has a method that compares a variable of T with another one.
When I specialize a class using this TDictionary with a type:
TSecurity = object
....
end;
e.g. TNewDict = class(TDictionary<String, TSecurity>);
it raise a compiler complaining that my TSecurity type has no operator =
defined.
But when I try to add like this:
TSecurity = object
....
class operator = (constref aLeft, aRight: TSecurity ): Boolean;
//<---compiler Error: Procedure or Function expected
end;
However, the following is OK
{$MODESWITCH advancedrecords}
TSecurity = record
....
class operator = (constref aLeft, aRight: TSecurity ): Boolean; //<---OK
end;
Why class operator is accepted for advanced records but not old fashion
object???
I cannot use advance record because it does have inherit methods. I need
method inheritance for my object.
Dennis
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailm
class has a method that compares a variable of T with another one.
When I specialize a class using this TDictionary with a type:
TSecurity = object
....
end;
e.g. TNewDict = class(TDictionary<String, TSecurity>);
it raise a compiler complaining that my TSecurity type has no operator =
defined.
But when I try to add like this:
TSecurity = object
....
class operator = (constref aLeft, aRight: TSecurity ): Boolean;
//<---compiler Error: Procedure or Function expected
end;
However, the following is OK
{$MODESWITCH advancedrecords}
TSecurity = record
....
class operator = (constref aLeft, aRight: TSecurity ): Boolean; //<---OK
end;
Why class operator is accepted for advanced records but not old fashion
object???
I cannot use advance record because it does have inherit methods. I need
method inheritance for my object.
Dennis
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailm