|
-
June 7th, 2011, 10:36 AM
#1
delete element from vector
Hi,
I have problem to delete element form my vector "prjs". The element includes visual control TEdit which stays on interface after I delete it. I found the reason was that the erase() didn't call destructor ~PRJNODE(); Do you know why?
Thanks in advance!
class PRJNODE
{
public:
TEdit * txtStatus;
TPopupMenu *popupMene1;
...
PRJNODE(TPanel*, TPopupMenu *);
PRJNODE();
~PRJNODE();
};
PRJNODE::PRJNODE(TPanel *frm, TPopupMenu *popup){
PRJNODE();
popupMene1=popup;
txtStatus = new TEdit(frm);
txtStatus->Parent = frm;
txtStatus->SetBounds(4, 100, 100, 20);
txtStatus->PopupMenu=popup;
};
PRJNODE::~PRJNODE(){
if (txtStatus){
txtStatus->Visible=false;
delete txtStatus; txtStatus=NULL;
}
};
typedef std::vector<PRJNODE*> PrjNodeVector;
class PRJCLS
{
public:
PrjNodeVector prjs;
void AddOnePrj();
...
};
void PRJCLS::AddOnePrj()
{
PRJNODE *newprj;
for (int i=0; i<5;i++) {
newprj=new PRJNODE(pnlTable, popup);
prjs.push_back(newprj);
}
...
for (int i=0; i<5;i++)
prjs.erase(prjs.begin()+i);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|