Re: dynamic_cast from base to another parent of derived class

2006-10-04 Thread Maxim Yegorushkin
Boris wrote: > [crossposted to gnu.g++.help] > > Boris wrote: > > Boris wrote: > >> [...] The code I talk about looks like this: > >> > >> if (typeid(b) == typeid(level2)) > >> { > >> const level1 *l1 = dynamic_cast(&b); > >> } > > > > I changed the code for testing purposes and replaced dynamic_

Re: dynamic_cast from base to another parent of derived class

2006-10-04 Thread Boris
Maxim Yegorushkin wrote: > [...] > > Why not just: > >if(level2 const* l2 = dynamic_cast(&b)) >{ >// no need comparing typeinfo's >} > > ? I want to cast to a level 1 class which is a parent of several level 2 classes. Otherwise you are right - I could cast to the actual type

Re: dynamic_cast from base to another parent of derived class

2006-10-04 Thread Boris
Boris wrote: >> I wonder how you reached such a conclusion. Where on that page do >> they say it does not work? > > The title is pretty clear I think: "dynamic_cast,throw, typeid don't > work with shared libraries". :-) They are talking about template > instantiations, vague linkage, not an exhaust

Re: dynamic_cast from base to another parent of derived class

2006-10-04 Thread Maxim Yegorushkin
Boris wrote: > Maxim Yegorushkin wrote: > > [...] > > > > Why not just: > > > >if(level2 const* l2 = dynamic_cast(&b)) > >{ > >// no need comparing typeinfo's > >} > > > > ? > > I want to cast to a level 1 class which is a parent of several level 2 > classes. Otherwise you are

Re: dynamic_cast from base to another parent of derived class

2006-10-04 Thread Boris
Maxim Yegorushkin wrote: > [...] >> if (typeid(b) == typeid(level2a) || typeid(b) == typeid(level2b) || >> typeid(b) == typeid(level2c)) >> { >> const level1 *l1 = dynamic_cast(&b); >> } >> >> Class level1 is the parent of all the level2 classes. I have to >> check for several types but don't ne