I was reading Never Call Virtual Functions during Construction or Destruction by Scott Meyer about basic C++ usage.
I was wondering if g++ has some compiler flags to warn about this bad coding that is really effective. If not what could be a way to code to do this check?
If I would code such kind of check I would approach this job by using a stack and inserting a piece of information at each call (a way to implement a call stack.
What I still need is a way to test whether a function is a virtual or whether a function is a constructor: Is there anyway to do that that you know? Something similar to a .NET ‘reflection’ idea?
Using
-Weffc++warns about this if (and only if)virtual void Transaction::logTransaction() constis pure, as it is in Meyer’s sample code: