void RemoveAll(){
cout << "delete :" << " Pointer:"<< (this)<< "--"<< this->name.c_str() << endl;
//TRACE("delete %s\n" , this->name);
vector
while (ite != v.end())
{
if (*ite != NULL)
{
((Component*)(*ite))->RemoveAll();
delete *ite;
*ite = NULL;
}
v.erase(ite);
ite = v.begin();
}
}
#include
#include
#include
#include
#include
using namespace std;
/** * 程序执行的入口点。 */
int main()
{
// 在标准输出中打印 "Hello, world!"
// std::cout << "Hello, world!" << std::endl;
cout << "Hello, world!" << endl;
cout << to_string(56) << endl;
//计划做一下vector的输入输出
vector
v.push_back(34);
v.push_back(35);
cout << v.size() << endl;
vector
while (it != v.end())
{
cout << *it << endl;
it++;
}
while (!v.empty())
{
v.erase(v.begin());
}
for (vector
if (*it == 2) {
it = v.erase(it);
} else {
++it;
}
}
///
vector
//释放内存
~Composite()
{
vector
while(ite != m_vecComp.end())
{
if(*ite != NULL)
{
cout<<"delete"<<(*ite)->GetName()<
*ite = NULL;
}
m_vecComp.erase(ite);
ite = m_vecComp.begin();
}
}
void Remove(Component* pComponent)
{
vector
for(ite = m_vecComp.begin(); ite != m_vecComp.end(); ite++ ){
if((*ite)->GetName() == pComponent->GetName())
{
if(*ite != NULL)
{
delete *ite;
*ite = NULL;
}
m_vecComp.erase(ite);
break;
}
}
}
//
//测试查找后移除表中的元素
void remove( float xy ,float z)
{
for(vector
it != vN.end() ; ++it)
{
if((*it)->x == xy && (*it)->z == z)
{
delete (*it);
(*it) = NULL;
vN.erase(it);
break;
}
}
}
///
cout << v.size() << endl;
int a[3] = {3, -2, 12};
int b[3] = {2, 1, 1};
int k = (b[0] / a[0]);
int c1 = b[1] - k * a[1];
cout << c1 << endl;
//计划做一下set的输入输出
set
s.insert(25);
s.insert(28);
s.insert(20);
set
sit = s.begin();
while (sit != s.end())
{
cout << *sit << endl;
++sit;
}
//取得第一个数值
int s1 = *(s.begin());
cout << s1 << endl;
//取得最后一个数值
int e1 = *(--s.end());
cout << e1 << endl;
//删除清空
while (!s.empty())
{
s.erase(s.begin());
}
s.clear();
//计划做一下list的输入输出
list
l.push_back(5);
l.push_back(8);
list
while (lit != l.end())
{
cout << *lit << endl;
lit++;
}
while (!l.empty())
{
l.erase(l.begin());
}
cout << "all ok !..." << endl;
return 0;
}