Answer the question
In order to leave comments, you need to log in
Change object in std::vevtor to another type
What is the point, there is a vector of pointers to the base class std::vector Mas;
this is how it fills up
void __fastcall TForm2::Button1Click(TObject *Sender)
{
String name=Edit2->Text;
if (RadioGroup2->ItemIndex==0) {
CPointIndic *tmp =new CPointIndic;
tmp->setName(name);
Mas.push_back(tmp);
Form1->updateList(Form1->List);
}
if (RadioGroup2->ItemIndex==1) {
CMenuIndic *tmp =new CMenuIndic;
tmp->setName(name);
Mas.push_back(tmp);
Form1->updateList(Form1->List);
}
if (RadioGroup2->ItemIndex==2) {
CCircleIndic *tmp =new CCircleIndic;
tmp->setName(name);
Mas.push_back(tmp);
Form1->updateList(Form1->List);
}
Close();
}
int index = List->ItemIndex;
if (index>=0) {
String name = Mas[index]->getName();
int n = StrToInt(InputBox("","",""));
switch(n)
{
case 1 :
delete Mas[index];
CPointIndic *tmp = new CPointIndic;
Mas.insert(index+1,tmp);
break;
}
}
}
Answer the question
In order to leave comments, you need to log in
Insert, for example, cannot insert by position number.
typedef std::vector<int>::iterator vector_iter;
vector_iter iter = Mas.begin() + (index + 1);
Mas.insert(iter, tmp);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question