新微赢技术网
标题:
向量容器的问题
[打印本页]
作者:
夜神君
时间:
2009-11-4 02:17
标题:
向量容器的问题
下面的程序我想输出a1的值该怎么写呢?
#include<vector>
#include<iostream>
using namespace std;
int i=0;
int j=0;
class Cdemo
{
public:
Cdemo():str(NULL)
{
cout<<"constructor:"<<i++<<endl;
};
Cdemo(const Cdemo &cd)
{
cout<<"copy constructor:"<<i++<<endl;
this->str=new char[strlen(cd.str)+1];
strcpy(str,cd.str);
};
~Cdemo()
{
if(str)
{
cout<<"destructor:"<<j++<<endl;
delete [] str;
}
};
char *str;
};
int main()
{
Cdemo d1;
d1.str=new char[32];
strcpy(d1.str,
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2