What will be the output of the following C++ program? #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 fault b) “Constructor called” five times and then “Destructor called” five times c) “Constructor called” five times and then “Destructor called” once d) Error
What will be the output of the following C++ program? #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 fault b) “Constructor called” five times and then “Destructor called” five times c) “Constructor called” five times and then “Destructor called” once d) Error
Share
b) “Constructor called” five times and then “Destructor called” five times