#include <iostream>
using namespace std;
class A
{
public:
A()
{
cout<<"ctor called"<<endl;
}
~A()
{
cout<<"Destructor called"<<endl;
}
A& operator=(const A &a)
{
cout<<"Copy assignment operator called"<<endl;
return *this;
}
};
int main()
{
A a;
A aa[2];
aa[0] = a;
}
3 times default constructor is called; 1 time copy assignment operator is called; 3 times destructor is called.
Question: Shouldn't the destructor be called 4 times?