Overriding Object::ToString()

E

etam

I wouldn't have thought so. Which version of VS are you using?
2005...

Your code in that picture isn't precisely what's shown at that
previous link, so what else is different?

It is the same... I've copied and pasted it.
Do you have a small self contained example that reproduces this?

I don't really understand what do You mean ;).

Thanks,
Etam.
 
D

David Lowndes

Your code in that picture isn't precisely what's shown at that
It is the same... I've copied and pasted it.

It's not, the name has changed at the very least.
I don't really understand what do You mean ;).

An entire single file that compiles - just stick everything in the
main source file of a console project that reproduces the issue for
you (since what you showed is fine for me).

Dave
 
P

Peter Anthony

Why does String::ToString even exist? Why is there a method that converts a
String to a String? Isn't that a no-op? ;) I can see why you'd want to
override it, it should do nothing as it is...

And how does one find out what built-in methods are virtual/overridable? I
had no idea I could redefine ToString( ) for example. By experimentation
only, or is there a reference for this? MSDN2 isn't much help, you have to
know the answer before you can look up the question!!! lol
 
B

Ben Voigt [C++ MVP]

Peter Anthony said:
Why does String::ToString even exist? Why is there a method that converts
a

So that you can call ToString on *any* object.

String to a String? Isn't that a no-op? ;) I can see why you'd want to

Yes, it is a no-op.
override it, it should do nothing as it is...

And how does one find out what built-in methods are virtual/overridable? I
had no idea I could redefine ToString( ) for example. By experimentation
only, or is there a reference for this? MSDN2 isn't much help, you have to
know the answer before you can look up the question!!! lol

You're right about that, even the class member list on msdn doesn't indicate
virtual-ness.

I think Reflector indicates virtual members with a different icon though
(there seems to be a correlation between the double pink box and
virtual/override functions).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top