c++constructorvirtual

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


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


Solution

  • 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.