Double free or corruption after queue::push
问题 #include <queue> using namespace std; class Test{ int *myArray; public: Test(){ myArray = new int[10]; } ~Test(){ delete[] myArray; } }; int main(){ queue<Test> q Test t; q.push(t); } After I run this, I get a runtime error "double free or corruption". If I get rid of the destructor content (the delete ) it works fine. What's wrong? 回答1: Let's talk about copying objects in C++. Test t; , calls the default constructor, which allocates a new array of integers. This is fine, and your expected