Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get rid of: W1010 Method 'ToString' hides virtual method of base type 'TObject' ?

305 views
Skip to first unread message

Skybuck Flying

unread,
Dec 20, 2011, 1:02:19 AM12/20/11
to
Hello,

My code has a class which has the following function:

type
TSomeClass =
public
function ToString( ParaFilename : string; ParaGenerations : int64 )
: string; virtual;
end;

Delphi XE2 has added ToString method to TObject, now Delphi nags and gives
the following warning:

"
W1010 Method 'ToString' hides virtual method of base type 'TObject'
"

How do I get rid of this warning ?

I tried override, overload directives but no luck so far ;)

Bye,
Skybuck.

Peter

unread,
Dec 20, 2011, 12:47:22 PM12/20/11
to
Add "reintroduce", that tells the compiler that you hopefully know what
you are doing.


--
Peter Below

Erick Engelke

unread,
Dec 22, 2011, 7:10:08 PM12/22/11
to
When going to a new version of a compiler, if you get a name conflict, I
think it's smartest to rename all instances of the function in your
codebase.

Problems related to name conflicts tend to be subtle and hard to figure
out long after you've forgotten you kludged it against the will of the
compiler.

Erick

Skybuck Flying

unread,
Dec 23, 2011, 1:28:59 AM12/23/11
to


"Peter" wrote in message news:xn0hn34r...@news.online.de...
Ok thanks for the tip:

This worked:

function ToString( ParaFilename : string; ParaGenerations : int64 ) :
string; reintroduce; virtual;

This however did not work:

function ToString( ParaFilename : string; ParaGenerations : int64 ) :
string; virtual; reintroduce;

The first one seems to make somewhat more sense, it seems to tell the
compiler: "it's ok to override behaviour or subplant it, and then it's ok to
make it virtual..."

While the second would probably mean something else ;)

Bye,
Skybuck.




0 new messages