Vidyalelo
C++ Programming · Q74

Object Oriented Programming in C++

Programming · C++ Programming · question 74

Q74

What will be the output of the following C++ code? #include using namespace std; class A public: A() cout<<"Constructor called "; ~A() cout<<"Destructor called "; ; int main(int argc, char const *argv[]) A *a = new A[5]; delete[] a; return 0;

A.
"Constructor called" five times and then "Destructor called" five times
Answer
B.
"Constructor called" five times and then "Destructor called" once
C.
Error
D.
Segmentation fault

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board