Reputation: 3278
I am almost done with migrating my software for .NET environment. Now I am going through all the warnings and cleaning them up. Then, I ran into this problem.
Here is my class:
TColorObj = class
value:double;
thecolor:Color;
Constructor;
method ReadColor(bdr:BinaryReader);
method WriteColor(bdw:BinaryWriter);
method Clone:TColorObj;
method ToString:String; Override; <<<<----this method is raising error.
end;
The error is "Cannot override method with lower access than base method." However, if I remove the key word, Override, it raises a warning message, "ToString" hides a parent method." TColorObj class is not inherited from any base class as you can see.
So, do I make the class TColorObj public?
Any help or hints will be appreciated.
Upvotes: 0
Views: 78
Reputation: 700152
Every class is inheriting from another class, if you don't specify a class you are inheriting from the Object
class.
You are overrinding the ToString
method which is public, so you have to make the overriding method public also.
Upvotes: 1
Reputation: 125620
You need to make the ToString
method public in visibility, which is what it is in TObject
. You can't move it from 'public' to a lower visibility in a descendant.
TColorObj = class
value:double;
thecolor:Color;
Constructor;
method ReadColor(bdr:BinaryReader);
method WriteColor(bdw:BinaryWriter);
public
method Clone:TColorObj;
method ToString:String; Override; <<<<----this method is raising error.
end;
Upvotes: 4