0

Why C++ doesn't have virtual constructor?

I have googled many times to find the answer of this question... but never found a satisfactory answer. Can anyone answer - Why C++ doesn't have virtual constructor?

1st Apr 2017, 8:24 PM
Aditya Chauhan
Aditya Chauhan - avatar
1 Answer
0
Virtual allows us to call a function without knowing the exact type of the object. In order to construct something you need to know the exact type, thus a constructor cannot be virtual. More on this here: http://www.stroustrup.com/bs_faq2.html#virtual-ctor
1st Apr 2017, 8:34 PM
Dennis
Dennis - avatar