Effective C++ item 9: Never call virtual functions during construction or destruction.

Don’t call virtual functions during construction or destruction, because such calls will never go to a more derived class than that of the currently executing constructor or destructor. In other words, it will call the version of base class rather than that of derived class. For example if you has a Transaction base class which keeps the log of buy and sell transactions. Probably you will write code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Transaction
{
public:
Transaction()
{
...
logTransaction();
}

virtual void logTransaction() const = 0;
};

class BuyTransaction: public Transaction
{
public:
virtual void logTransaction() const {...}
...
};

class SellTransaction: public Transaction
{
public:
virtual void logTransaction() const {...}
...
};

In the code above, the logTransaction() method in the constructor of Transaction base class will always call Transaction::logTransaction() rather than BuyTransaction::logTransaction() or SellTransaction::logTransaction(), this is because the object is as if it were of the base type during base class construction. In the example above, since the logTransaction() is pure virtual in the base class you will probably get a warning or error from compiler. If logTransaction() is just a virtual function, then you are highly possible to debug to hell to find out why your derived methods are never called.

Reference:
“Effective C++” Third Edition by Scott Meyers.