COMPILER DESIGN

TOOLS AND TECHNIQUES FOR COMPILER DESIGN

LLVM

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
In C++, both constructors and destructors can be virtual
A
True
B
False
C
Either A or B
D
None of the above
Explanation: 

Detailed explanation-1: -Explanation: Constructor and Destructor this can not be declared as virtual. Explanation: For automatic objects, constructors and destructors are called each time the objects Enter and leave scope.

Detailed explanation-2: -Virtual destructors in C++ are used to avoid memory leaks especially when your class contains unmanaged code, i.e., contains pointers or object handles to files, databases or other external objects. A destructor can be virtual.

Detailed explanation-3: -There can be only one destructor in a class.

Detailed explanation-4: -Constructors can take arguments but destructors cannot. Destructors can be overloaded but constructors cannot be overloaded.

There is 1 question to complete.