This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem with dynamic_cast
- From: Markus Gerwinski <markus at gerwinski dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 25 Mar 2003 15:55:26 +0100
- Subject: Problem with dynamic_cast
Hello,
the following test program refuses to compile:
#include <iostream>
#include <typeinfo>
class Pruzzel {
}; // Pruzzel
class Proe: public Pruzzel {
}; // Proe
int main ( int argc, char** argv ) {
Pruzzel *schale = new Proe ();
if ( Proe *kern = dynamic_cast < Proe* > ( schale ) ) {
std::cout << "Amazooka" << std::endl;
} else {
std::cout << ":-6" << std::endl;
} // if
} // main
When trying to build it with "g++ test.cc -o test", I get the error message:
test.cc: In function `int main(int, char**)':
test.cc:15: cannot dynamic_cast `schale' (of type `class Pruzzel*') to type `
class Proe*' (source type is not polymorphic)
What am I doing wrong here?
Thanks in advance,
Markus