本文整理汇总了C++中Quote::net_price方法的典型用法代码示例。如果您正苦于以下问题:C++ Quote::net_price方法的具体用法?C++ Quote::net_price怎么用?C++ Quote::net_price使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quote
的用法示例。
在下文中一共展示了Quote::net_price方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_total
double print_total(std::ostream& os, const Quote& item, size_t n)
{
double ret = item.net_price(n);
os << "ISBN:" << item.isbn() << "# sold: " << n << "total due: "
<<ret << std::endl;
return ret;
}
示例2: main
// for test
int main(int argc, char **argv)
{
Quote q("asd", 10.5);
Bulk_Quote b_q("fuck", 10.5, 20, 0.2);
Quote *p;
p = &q;
cout << "20本asd的总价格为:" << p->net_price(20) << endl;
p->debug();
p = &b_q;
cout << "20本fuck的总价格为:" << p->net_price(20) << endl;
p->debug();
system("pause");
return 0;
}
示例3: main
int main()
{
Bulk_quote bulk_quote("bulk_quote_1", 10.10, 10, 0.5);
// The pointer is of static type Quote, but it's dynamic type is Bulk Quote
// Because of polymorphism the Bulk Quote implementation of the net_price()
// method gets called.
Quote *quote_pointer = &bulk_quote;
quote_pointer->net_price(5);
// The reference is of static type Quote, but it's dynamic type is Bulk Quote
// Like with the pointer, the Bulk Quote implementation of the net_price()
// method gets called.
Quote "e_reference = bulk_quote;
quote_reference.net_price(5);
// The static type of this variable is Quote. Here the Bulk Quote object
// gets upcasted. The Quote part of bulk_quote gets copied into quote, but
// the rest is not handled. Because of the cast the Quote implementation of
// the net_price() method gets called.
Quote quote = bulk_quote;
quote.net_price(5);
return 0;
}
示例4: print_total
double print_total(ostream& os, const Quote& item, size_t number){
double ret = item.net_price(number);
os << "ISBN: " << item.isbn() << " # sold: " << number
<< " total due: " << ret << endl;
return ret;
}
示例5: print_total
double print_total(std::ostream& out, const Quote& item, std::size_t n)
{
// depending on the type of the object bound to the item parameter
// call corresponding functuon either Quote::net_price or Bulk_quote::net_price
double ret = item.net_price(n);
out << "IBSN: " << item.isbn() << " # sold: " << n << " total due: " << ret << std::endl;
return ret;
}
示例6: print_total
// non-member
double print_total(std::ostream &os, const Quote &item, size_t n)
{
// depending on the type of the object bound to the item parameter
// calls either Quote::net_price or Bulk_quote::net_price
double ret = item.net_price(n);
os << "ISBN: " << item.isbn() // calls Quote::isbn
<< " # sold: " << n << " total due: " << ret << std::endl;
return ret;
}
示例7: print_total
double print_total(ostream& os, Quote const& item, size_t sold)
{
double net_price = item.net_price(sold);
os << "isbn: " << item.isbn() << ", sold: " << sold
<< ", total due: " << net_price << endl;
return net_price;
}
示例8: main
int main()
{
Quote base("000111", 50);
print_total(cout, base, 10); //calls Quote::net_price
Bulk_quote bulk("000111", 50, 5, 0.19);
print_total(cout, bulk, 10); //calls Bulk_quote::net_price
Quote *baseP = &bulk;
cout << baseP->net_price(10) << endl; //calls Bulk_quote::net_price
cout << baseP->Quote::net_price(10) << endl; //calls Quote::net_price
system("pause");
}
示例9: printTotal
void printTotal(ostream& os, const Quote& book, const size_t bookNum)
{
os << book.isbn() <<":" <<book.net_price(bookNum);
}