Overriding Object::ToString()

  • Thread starter Thread starter Etam
  • Start date Start date
E

Etam

Hi,

why I can not override it?

This line: virtual String^ ToString() override = Object::ToString;
produces this error: cannot override base class method
'System::Object::ToString'.

Why is that?

Tnaks in advance,
Etam.
 
Etam said:
why I can not override it?

This line: virtual String^ ToString() override = Object::ToString;
produces this error: cannot override base class method
'System::Object::ToString'.

Why is that?

I'm not familiar with the C++ syntax, but perhaps if you showed a
complete demonstration it would be easier to see what's wrong?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Hmm. Looking at a couple of online examples, my guess is that you don't
need to respecify "virtual". On the other hand, that wouldn't really
fit with the compiler message...

Sorry not to be able to help you further :(

When I remove virtual i get the error:
'override' requires 'virtual' :(

The strange thing is that this:
http://pastebin.com/m4661ce7b
WORKS :/.
 
Etam said:
When I remove virtual i get the error:
'override' requires 'virtual' :(

The strange thing is that this:
http://pastebin.com/m4661ce7b
WORKS :/.

Hmm.

Can you just put the override in the CPP file without declaring it in
the .h file perhaps?

I'd suggest asking in the specific C++ group though - you're bound to
get an answer there.
 
Back
Top