Answer Posted / meet
Constructor cannot be virtual. Because C++ is statically typed language. It is meaningless to the C++ compiler to create the object polymorphically. But it is possible to achieve behaviour like virtual constructor. This can be done by using factory design pattern.
Visit this link to know more about virtual constructor:
http://www.geeksforgeeks.org/advanced-c-virtual-constructor/
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What new()is different from malloc()?
What happens if a pointer is deleted twice?
Why #include is used?
Can recursive program be written in C++?
What is difference between array and vector in c++?
Explain the difference between c & c++?
What is a pdb file?
What is ios :: in in c++?
Do the names of parameters have to agree in the prototype, definition, and call to the function?
What is a base class?
What are the defining traits of an object-oriented language?
What are shallow and deep copy?
What c++ is used for?
What are the rules about using an underscore in a c++ identifier?
What is the difference between public and private data members?