C++ | Misc C++ | Question 6

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

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


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


Answer: (D)

Explanation:

Quiz of this Question



My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.