Menu

#46 CPPUnit don't support dynamic_cast?

open
nobody
None
5
2005-03-29
2005-03-29
Anonymous
No

Hi:
When I use dynamic_cast cast base_class to
derive_class. the program will print following message
"uncaught exception of type __non_rtti_object
-Access violation - no RTTI data!"
How can I resovle this problem.

I show the files PayrollTest.h and main.h as following

//PayrollTest.h
class PayrollTest: public CPPUNIT_NS::TestFixture
{
public:
// PayrollTest (std::string name) : TestFixture (name) {}

virtual void setUp();
virtual void teardown();

protected:
void TestAddSalariedEmployee();

private:
CPPUNIT_TEST_SUITE(PayrollTest);
CPPUNIT_TEST(TestAddSalariedEmployee);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(PayrollTest);

//main.h
int main()
{
CPPUNIT_NS::TestResult r;
CPPUNIT_NS::TestResultCollector result;
r.addListener( &result );

CPPUNIT_NS::TestFactoryRegistry::getRegistry).makeT
est()->run( &r );
CPPUNIT_NS::TextOutputter out( &result, std::cout );
out.write();
return 0;
}

Thanks in advance

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.