我这样说了吗?
Class A
{
private:
vector <B *> pB;
public:
A();
A(int tag);
~A();
}
A::A(int tag){
for (i=0; i != tag, i++)
pB.push_back(new B());
}
为了创造并非一个整体,而是一个构成,我只必须在主人中增加:
A::~A(){
vector <B *>::iterator citer = pB.begin();
while (citer != pB.end())
delete *(citer++);
pB.clear();
}
is it right? Thank you