+2 votes
in C Plus Plus by

Consider the following given program and choose the most appropriate output from the given options:

#include <iostream>  

using namespace std;  

class A{  

public:  

    A(){  

        cout<<"Constructor called\n";  

       }  

    ~A(){  

        cout<<"Destructor called\n";  

        }   

};  

int main(int argc, char const *argv[])  

{  

    A *a = new A[5];  

    delete[] a;  

    return 0;  

}  

a) Segmentation failure.

b) Error.

c) The Constructor will be invoked five times, and after that destructor will be invoked only once.

d) The Constructor will be invoked five times, and after that destructor will also be invoked five times.

1 Answer

0 votes
by

d) The Constructor will be invoked five times, and after that destructor will also be invoked five times.

Related questions

0 votes
asked Nov 16, 2021 in Azure by Robin
+1 vote
asked Aug 30, 2022 in AWS by sharadyadav1986
...