topical media & game development
professional-program-17-CostlyLanguageFeatures-test.c
? /
professional-program-17-CostlyLanguageFeatures-test.c
// test.cpp
include <iostream>
include <exception>
using namespace std;
class base
{
public:
base() {}
virtual ~base() {}
};
class derived : public base {};
int main(int argc, char** argv)
{
base* b = new derived();
derived* d = dynamic_cast<derived*>(b); // use RTTI
if (d == NULL) {
throw exception(); // use exceptions
}
return (0);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.