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


C++ Inventory::search方法代码示例

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


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

示例1: main

int main(int argc, const char *argv[])
{
    Inventory inventory;
    GuitarSpec whatErinLikes = GuitarSpec(GBuilder::FENDER, "Stratocastor",
                                  GType::ELECTRIC, GWood::ALDER, GWood::ALDER);


    //add a guitar
    GuitarSpec newspec = GuitarSpec(GBuilder::FENDER, "Stratocastor",
                                    GType::ELECTRIC, GWood::ALDER, GWood::ALDER);
    inventory.addGuitar("V95693", 1499.95, newspec) ;
    inventory.addGuitar("V9512", 1549.95, newspec) ;



    try{
        list<Guitar> guitars = inventory.search(whatErinLikes);

        cout << "Erin, you might like these guitars:" << endl;
        for ( list<Guitar >::const_iterator i = guitars.begin(); i != guitars.end(); i++){
            GuitarSpec spec = i->getSpec();

            cout <<"  We have a " << spec.getBuilder()
                 <<" " << spec.getModel()
                 <<" " << spec.getType() << " guitar:" << endl
                 <<"     " << spec.getBackWood() << " back and sides," << endl
                 <<"     " << spec.getTopWood() << " top.\n  You can have it for only $"
                 << i->getPrice() << "!\n  ----"  << endl;
        }
    }
    catch(InventoryException &ie) {
        cout << "Sorry, Erin, we have nothing for you." << endl;
    }
    return 0;
}
开发者ID:samuelololol,项目名称:HFOOADinCpp,代码行数:35,代码来源:main.cpp


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