FAQ Database Discussion Community


How to enforce parent / derived relationship of two independent classes inside a container?

c++,pointers,polymorphism,containers,vtable
Consider the following class definitions: #include <string> class CParty { public: CParty(); virtual ~CParty(); int m_nId; }; class CPartyEx : public CParty { public: CPartyEx(); ~CPartyEx(); std::string m_sName; }; class CTransaction { public: CTransaction(); virtual ~CTransaction(); int m_nClassNo; }; class CTransactionEx : public CTransaction { public: CTransactionEx(); ~CTransactionEx(); std::string m_sDesc;...

CRTP vs devirtualization flag in GCC

c++,gcc,vtable,crtp
I'm starting to study the CRTP idiom, and I've noticed that GCC has a fdevirtualize flag that should allow to transform when possible vtable calls to direct calls. While the CRTP can be applied with any (C++ compliant) compiler, if I want to develop only with gcc, can I avoid...

understanding of multiple inheritance for c++

c++,this,multiple-inheritance,virtual-functions,vtable
I'm reading multiple inheritance for c++ An Example in the paper:(page 377) class A {virtual void f();}; class B {virtual void f(); virtual void g();}; class C: A, B {void f();}; A* pa = new C; B* pb = new C; C* pc = new C; pa->f(); pb->f(); pc->f(); pc->g()...

How do I resolve the “undefined reference to `vtable for <>” error?

c++,c++11,vector,constructor,vtable
I am a C++ beginner. I have a singleton 'Manager' class as shown below and I get the following error when I build the project in Eclipse: ../src/Manager.hpp:28: undefined reference to 'vtable for Manager' [The below code is the minimum (almost) to be run in your dev environment or IDEs...