+ 1

C++: Why constructor cannot be virtual but destructor can?

constructor destructor in c++

1st Oct 2018, 4:26 PM
Sumit
1 ответ
+ 2
Because, constructor is not "invoked". It is called only once when an object is declared. So, a constructor cannot be made virtual in C++. Virtual destructors are important to prevent memory leaks, and monitor the system
1st Oct 2018, 4:57 PM
Shimmu