Search code examples
c++type-conversionvirtual

Can conversion function be virtual in C++?


I am curious to know that is it possible to have conversion function that is virtual? If yes, it would be better if you explain it using an appropriate program. Is the call to conversion function will be resolved at runtime if it is virtual?


Solution

  • This simple answer is yes, conversion functions can be virtual, so long as they are class methods.