|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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/ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Feb 27, 1:49pm, 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. |
|
![]() |
| Outils de la discussion | |
|
|