Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Overloading typeid operator (http://www.velocityreviews.com/forums/t594464-overloading-typeid-operator.html)

Sarath 02-27-2008 04:04 AM

Overloading typeid operator
 
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

Micah Cowan 02-27-2008 04:49 AM

Re: Overloading typeid operator
 
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/

Sarath 02-27-2008 05:18 AM

Re: Overloading typeid operator
 
On Feb 27, 1:49*pm, Micah Cowan <mi...@cowan.name> 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.


All times are GMT. The time now is 12:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.