Open In App

C++ | Misc C++ | Question 6

Like Article
Like
Save Article
Save
Share
Report issue
Report

Would destructor be called, if yes, then due to which vector?




#include <iostream>
#include <vector>
using namespace std;
  
class a
{
public :
    ~a()
    {
        cout << "destroy";
    }
};
int main()
{
   vector <a*> *v1  = new vector<a*>;
   vector <a> *v2  = new vector<a>;
   return 0;
}


(A) v1
(B) v2
(C) v1 and v2
(D) no destructor call


Answer: (D)

Explanation:

Quiz of this Question


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads