473,416 Members | 1,544 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,416 software developers and data experts.

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
Feb 27 '08 #1
2 2754
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/
Feb 27 '08 #2
On Feb 27, 1:49*pm, Micah Cowan <mi...@cowan.namewrote:
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.
Feb 27 '08 #3

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

Similar topics

5
by: | last post by:
Hi all, I've been using C++ for quite a while now and I've come to the point where I need to overload new and delete inorder to track memory and probably some profiling stuff too. I know that...
7
by: Hendrik Schober | last post by:
Hi, I have a problem, that boils down to the following code: #include <iostream> #include <typeinfo> class Test1 {}; class Test2 {}; class Test3 {};
19
by: Marco Jez | last post by:
Hi everyone! I would like to use the reference returned by typeid as key in a std::map. Is it safe to assume that typeid(T) (where T is a type name) will always return the same reference to the...
5
by: luca regini | last post by:
I have this code class M { ..... T operator()( size_t x, size_t y ) const { ... Operator overloading A ....} T& operator()( size_t x, size_t y )
2
by: brzozo2 | last post by:
Hello, this program might look abit long, but it's pretty simple and easy to follow. What it does is read from a file, outputs the contents to screen, and then writes them to a different file. It...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
5
by: raan | last post by:
What I am trying to achieve here is depicted in the small program below. // Wrapit.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <map> #include...
11
by: dascandy | last post by:
Hello, I was wondering, why is overloading operator. (period) forbidden? It would make a few odd applications possible (dynamic inheritance and transparent remote method invocation spring to my...
11
by: [rob desbois] | last post by:
Hi all, I have a set of classes which implement the virtual constructor idiom. I had a slicing problem which resulted when I forgot to override the clone() function in a derived class. Is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.