Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Overloading typeid operator

Reply
Thread Tools

Overloading typeid operator

 
 
Sarath
Guest
Posts: n/a
 
      02-27-2008
Hello All

Is it possible to overload typeid operator? In my understanding it's
not possible Could you please provide more information on same?

Regards,
Sarath
 
Reply With Quote
 
 
 
 
Micah Cowan
Guest
Posts: n/a
 
      02-27-2008
Sarath wrote:
> Hello All
>
> Is it possible to overload typeid operator? In my understanding it's
> not possible Could you please provide more information on same?


It is not possible. Neither is overloading sizeof, or any of ., .*, ::
or ?:.

All of these operators have important and specific meanings, and would
be severely undermined if users were able to change their meanings.

For typeid, for instance, the whole point is to uniquely identify a
type. If you're trying to make a user-defined type "look" like another
type, you're better off taking advantage of polymorphism and/or
type-conversion (a lá opertor bool(), etc) semantics; typeid is, as it
ought to be, sacrosanct.

--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
 
Reply With Quote
 
 
 
 
Sarath
Guest
Posts: n/a
 
      02-27-2008
On Feb 27, 1:49*pm, Micah Cowan <(E-Mail Removed)> wrote:
> Sarath wrote:
> > Hello All

>
> > Is it possible to overload typeid operator? In my understanding it's
> > not possible Could you please provide more information on same?

>
> It is not possible. Neither is overloading sizeof, or any of ., .*, ::
> or ?:.
>
> All of these operators have important and specific meanings, and would
> be severely undermined if users were able to change their meanings.
>
> For typeid, for instance, the whole point is to uniquely identify a
> type. If you're trying to make a user-defined type "look" like another
> type, you're better off taking advantage of polymorphism and/or
> type-conversion (a lá opertor bool(), etc) semantics; typeid is, as it
> ought to be, sacrosanct.
>
> --
> Micah J. Cowan
> Programmer, musician, typesetting enthusiast, gamer...http://micah.cowan.name/


Thanks a lot for the information. It's clear now.

Regards
Sarath.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
overloading operator->*() and operator->() gob00st@googlemail.com C++ 11 02-20-2009 08:52 PM
user defined conversion operator or operator overloading? hurcan solter C++ 3 08-29-2007 07:39 PM
Why is overloading operator. (member operator) forbidden? dascandy@gmail.com C++ 11 05-16-2007 07:54 PM
typeid operator Marco Jez C++ 20 10-31-2004 09:13 PM
Operator overloading on "default" operator John Smith C++ 2 10-06-2004 10:22 AM



Advertisments