Can we make a class copy constructor virtual in C++

user1295465 picture user1295465 · Mar 27, 2012 · Viewed 21.3k times · Source

Can we make a class copy constructor virtual in C++? How to use?

Answer

Luchian Grigore picture Luchian Grigore · Mar 27, 2012

No you can't, constructors can't be virtual.

C++03 - 12.1 Constructors

4) A constructor shall not be virtual (10.3) or static (9.4). [...]

If you need something like this, you can look up the virtual constructor idiom here.