#include <vector>
#include <iostream>
using namespace std;
class cItem{
public:
char *str;
cItem(const char * str = 0) {
if( str )
strcpy(cItem::str = new char[1 + strlen(str)], str);
else
cItem::str = 0;
cout<<"DFLT CONSTRUCT : "<<(cItem::str ? cItem::str : "null")<<endl;
}
cItem(const cItem &pCopy)
{
char * str = const_cast< char *>(pCopy.str);
if( str )
strcpy(cItem::str = new char[1 + strlen(str)], str);
else
cItem::str = 0;
cout<<"COPY CONSTRUCT : "<<(cItem::str ? cItem::str : "null")<<endl;
}
~cItem(){
cout<<"DESTRUCT : "<<(cItem::str ? cItem::str : "null")<<endl;
delete str;
}
};
int main(){
cItem itemArr[] = {
cItem("test1"),
cItem("test2"),
cItem("test3")};
vector< cItem > itemVec(itemArr, itemArr + 3);
cout<<"INITIAL"<<endl;
cout<<itemVec[0].str<<endl;
cout<<itemVec[1].str<<endl;
cout<<itemVec[2].str<<endl;
cout<<"RESIZE"<<endl;
itemVec.resize(5);
cout<<itemVec[0].str<<endl;
cout<<itemVec[1].str<<endl;
cout<<itemVec[2].str<<endl;
cout<<"EOP"<<endl;
cin.get();
return 0;
}