473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Overriding Object::ToString()

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.

Nov 7 '07 #1
5 2129
Etam <od*******@gmail.comwrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 8 '07 #2
Etam <od*******@gmail.comwrote:
There is the code:

http://eugeneciurana.com/pastebin/pa....php?show=5225
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 :(

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 9 '07 #4
On 9 Lis, 12:55, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
Etam <odwrot...@gmail.comwrote:
There is the code:
http://eugeneciurana.com/pastebin/pa....php?show=5225

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 :(

--
Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
When I remove virtual i get the error:
'override' requires 'virtual' :(

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

Nov 9 '07 #5
Etam <od*******@gmail.comwrote:
On 9 Lis, 12:55, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
Etam <odwrot...@gmail.comwrote:
There is the code:
>http://eugeneciurana.com/pastebin/pa....php?show=5225
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 :/.
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 10 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Joe | last post by:
Stupid question, but I'm really stuck I have a class that overrides ToString(). When this class is cast back to Object, and ToString() called, Object.ToString() is called instead. I've tried...
0
by: ºa¤Ö | last post by:
Dear All Experts I would like to know what's the different between Convert.ToString(object) object.ToString() (string)object ?? thanks
2
by: Etam | last post by:
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...
11
by: etam | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.