本文整理汇总了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;
}