Q) Not using virtual destructor feature in a C++ object oriented programing can cause
- Memory leak
- An Issue in creating object of the class
- An issue in calling base class destructor
Virtual destructor is used to maintain the hierarchy of destructor calls for polymorphic classes in inheritance. If we don’t use it then it may cause resource leak or memory leak.
Q) Which C++ oops feature is related to re-usability?
Inheritance feature is used for concept of code re-usability as in inheritance a class can inherit properties and functions of existing well written class.
Abstraction : Provide only necessary information to client code.
Encapsulation: Hide complexity. e.g. by wrapping private class data members by functions. By making internal function of a class private and using interfaces etc.