当前位置: 首页>>代码示例>>C++>>正文


C++ Link::erase方法代码示例

本文整理汇总了C++中Link::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::erase方法的具体用法?C++ Link::erase怎么用?C++ Link::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Link的用法示例。


在下文中一共展示了Link::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main () {
    Link* norse_gods = new Link("Thor");
    norse_gods = norse_gods->insert(new Link("Odin"));
    norse_gods = norse_gods->insert(new Link("Zeus"));
    norse_gods = norse_gods->insert(new Link("Freia"));

    Link* greek_gods = new Link("Hera");
    greek_gods = greek_gods->insert(new Link("Athena"));
    greek_gods = greek_gods->insert(new Link("Mars"));
    greek_gods = greek_gods->insert(new Link("Poseidon"));
    
    Link* g = greek_gods->find("Mars");
    if (g) g->value = "Ares";

    Link* n = norse_gods->find("Zeus");
    if (n == norse_gods) norse_gods = n->next();

    n->erase();
    greek_gods = greek_gods->insert(n);
    
    print_all(norse_gods);
    cout << "======================" << endl;
    print_all(greek_gods);

    keep_window_open();
}
开发者ID:diversario,项目名称:cpp_book,代码行数:26,代码来源:Source.cpp

示例2: main

int main()
{
    Link* norse_gods = new Link("Thor");
    norse_gods = norse_gods->insert(new Link("Odin"));
    norse_gods = norse_gods->insert(new Link("Zeus"));
    norse_gods = norse_gods->insert(new Link("Freia"));

    Link* greek_gods = new Link("Hera");
    greek_gods = greek_gods->insert(new Link("Athena"));
    greek_gods = greek_gods->insert(new Link("Mars"));
    greek_gods = greek_gods->insert(new Link("Poseidon"));

    Link* p = greek_gods->find("Mars");
    if (p) p->value = "Ares";

    // Move Zeus into his correct Pantheon:
    {
        Link* p = norse_gods->find("Zeus");
        if (p) {
            if (p==norse_gods)
                norse_gods = p->next();
            p->erase();
            greek_gods = greek_gods->insert(p);
        }
    }

	norse_gods->add(new Link("loki"));
    // Finally, let's print out those lists:

	print_all(norse_gods);
    cout<<"\n";
	norse_gods=norse_gods->advance(2); // test advance
    print_all(norse_gods);
    cout<<"\n";

    print_all(greek_gods);
    cout<<"\n";
	cout<<greek_gods->node_count()<<endl; // test node count

	Link* god_list=new Link("Apollo");
	god_list=god_list->add(new Link("Aphrodite"));
	god_list=god_list->add(new Link("Artemis"));
	god_list=god_list->add(new Link("Hades"));
	god_list=god_list->first();
	print_all(god_list);
	cout<<endl;
	keep_window_open();
}
开发者ID:alanachtenberg,项目名称:CSCE-113,代码行数:48,代码来源:assign2pr2.cpp


注:本文中的Link::erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。