dynamic_cast Problem

Nathan Sidwell nathan@acm.org
Thu Dec 2 05:36:00 GMT 1999


"Georg C. F. Greve" wrote:
> As far as I know this should be done by dynamic_cast which would
> result in a function like this:

> Element*
> clone(const Element* source)
> {
> 
>   if ( Logfile* s = dynamic_cast<Logfile*>(source) )
>     return new Logfile(*s);

>
> element.cpp:69: cannot dynamic_cast `source' (of type `const class xservices::Element *') to type `class xservices::Logfile *'
5.2.7/1 [expr.dynamic.cast]  
	`The dynamic_cast operator shall not cast away constness'

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


More information about the Gcc mailing list