请大神帮忙看下这个程序
#include "stdafx.h"
#include <iostream>
#include <stack>
using namespace std;
class A
{
public:
A(const A& T)
{
this->a = T.a;
cout<<"调用拷贝构造"<<endl;
this->pbuff = new char[20];
memset(this->pbuff,0,20);
strcpy(this->pbuff,T.pbuff);
}
A(int element)
{
a = element;
pbuff = new char[20];
memset(pbuff,0,20);
sprintf(pbuff,"test %d",a);
cout<<"construct"<<a<<endl;
}
~A()
{
cout<<"end"<<a<<endl;
delete pbuff;
}
void print()
{
cout<<a<<","<<pbuff<<",0x"<<this<<endl;
}
private:
int a;
char* pbuff;
};
int main()
{
{
A a1(1),a2(2);
a1.print();
a2.print();
stack<A> stack1;
stack1.push(a1);
stack1.push(a2);
A &data = stack1.top();
//data.print();
stack1.pop();
data.print();
}
return 0;
}