hey friends,
I want to know is there any 'virtual constructor' in c++? This question has been asked to me twice in my college. Hope to get reply with sound explanations.
byeee
hey friends,
I want to know is there any 'virtual constructor' in c++? This question has been asked to me twice in my college. Hope to get reply with sound explanations.
byeee
Not really. There's a pattern that can be called virtual constructor, but it is not inherently supported by the language.
"Modern C++ Design" by Andrei Alexandrescu contains an implementation of the pattern.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
no, and you can't call virtual functions inside constructors either. The reason is that the vtable has not been assembled yet. There are however virtual destructors which in some uses are crucial.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter