PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Overloading typeid operator
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Overloading typeid operator

Réponse
 
LinkBack Outils de la discussion
Vieux 27/02/2008, 04h04   #1
Sarath
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
Vieux 27/02/2008, 04h49   #2
Micah Cowan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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/
  Réponse avec citation
Vieux 27/02/2008, 05h18   #3
Sarath
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Overloading typeid operator

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.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h12.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 4,78099 seconds with 11 queries