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


C++ Quote::net_price方法代码示例

本文整理汇总了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;
}
开发者ID:bowanggithub,项目名称:C-primer,代码行数:7,代码来源:ex15.3.main.cpp

示例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;
}
开发者ID:FreAkPoint,项目名称:Some-codes-about-Cpp-Primer-5th,代码行数:17,代码来源:15.11.cpp

示例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 &quote_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;
}
开发者ID:1e0nshe11,项目名称:Cpp-Primer,代码行数:25,代码来源:main.cpp

示例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;

}
开发者ID:FrankYanCheng,项目名称:C-plus-plus-primer-answers,代码行数:8,代码来源:EX15.6.cpp

示例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;
}
开发者ID:PraflyGod,项目名称:Cpp,代码行数:8,代码来源:Exercise15.11.cpp

示例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;
}
开发者ID:1e0nshe11,项目名称:Cpp-Primer,代码行数:10,代码来源:quote.cpp

示例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;
  }
开发者ID:keitee,项目名称:kb,代码行数:9,代码来源:cxx_case.cpp

示例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");
}
开发者ID:Larry955,项目名称:learnCPP,代码行数:14,代码来源:useQuote.cpp

示例9: printTotal

void printTotal(ostream& os, const Quote& book, const size_t bookNum)
{
    os << book.isbn() <<":" <<book.net_price(bookNum);
}
开发者ID:zmsunnyday,项目名称:Cpp-Primer,代码行数:4,代码来源:exc15_15.cpp


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