Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > typeof() not st...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9557 of 9593
Post > Topic >>

typeof() not standard?

by "Hakusa@[EMAIL PROTECTED] " <Hakusa@[EMAIL PROTECTED] > Apr 28, 2008 at 04:00 PM

I have two issues.

1) Given the objects item1 and item2, derived from type T, I need to
find out if item2 is derived from item1.

I solved this by learning (by accident) of the typeof() keyword...that
is apparently not standard. Nevertheless, it allowed me to write the
following line of code that presumably works...if only it would
compile.

> if( dynamic_cast< typeof( item1 ) >( item2 ) );

Interestingly enough,

> cout << dynamic_cast< typeof( item1 ) >( item2 );

does compile. Neither item1 or 2 is constant, in case that would
explain this.

My second issue is that I heard MS compilers do not typeof, so I'd
either have to steal from Boost or come up with a completely different
way to test inheritance so it would compile on my target machine

So, my goals for posting here are:
-- Find out how to make what I have compile, or find an alternative.
-- Learn what I can do to make my source compilable on MS compilers--
or if it would as it is (after I get it working).
-- Gain a deeper understanding for the material.

Thanks in advance.

PS: I'm using GNU. to compile this.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]




 4 Posts in Topic:
typeof() not standard?
"Hakusa@[EMAIL PROTE  2008-04-28 16:00:49 
Re: typeof() not standard?
nickf3 <nickf3@[EMAIL   2008-04-28 20:36:59 
Re: typeof() not standard?
Mathias Gaunard <loufo  2008-04-28 20:34:47 
Re: typeof() not standard?
Michiel.Salters@[EMAIL PR  2008-05-02 12:45:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 14:44:03 CDT 2008.