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


C++ Quote类代码示例

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


在下文中一共展示了Quote类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

int main()
{
    Quote q("aaa", 10.60);
    Bulk_quote bq("bbb", 111, 10, 0.3);
    Limit_quote lq("ccc", 222, 10, 0.3);

    /** @note   Not dynamic binding!
     *  The codes below are not dynamic binding. The compiler has known what the
     *  r refering to at compile time. As a result, the virtual function debug of
     *  the subobject is called.
     */
    Quote *r = &q;
    r->debug();
    std::cout << "\n";
    r = &bq;
    r->debug();
    std::cout << "\n";
    r = &lq;
    r->debug();
    std::cout << "\n";


    std::cout << "====================\n";

    q.debug();
    bq.debug();
    lq.debug();
    print_debug(q);
    print_debug(bq);
    print_debug(lq);
    return 0;
}
开发者ID:wrx1721267632,项目名称:primer,代码行数:32,代码来源:15.17.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

  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

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

示例8: main

int main()
{
	Bulk_quote bulk;
	Bulk_quote *bulkP = &bulk;	// static and dynamic types are the same
	Quote *itemP = &bulk;       // static and dynamic types differ
	bulkP->discount_policy();   // ok: bulkP has type Bulk_quote*
	itemP->discount_policy();   // error: itemP has type Quote*
	return 0;
}
开发者ID:chihyang,项目名称:CPP_Primer,代码行数:9,代码来源:Page617_scope.cpp

示例9: 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

示例10: 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

示例11: main

int main(int argc, char* argv[])
{
	/// Take file input either from command line or from console
	string fileName;
	cout << "profile name: ";
	if(argc > 1 ) {
		fileName = argv[1];
	}
	else {
		cin >> fileName;
	}
	cout << fileName << endl;


	/// Read the file till the end
	string inputData, line;
	
	/// Open the file stream
	ifstream inputFile (fileName); 
	
	/// If file stream succeeds
	if(inputFile) {
		while( getline (inputFile, line) ) {
			inputData.append(line);
		}
	}
	else {
		cout << "Error to open the profile file. Please check the file path." << endl;
		return -1;
	}

	/// Deserialized JSON fileName is represented in "pofile" object
	Profile profile;
	CJsonDeserializer::Deserialize( &profile, inputData );

	/// Generates quote with generated profile
	Quote q;
	cout << "Quote: " << std::fixed << std::setprecision(2) << q.GetQuote(profile) << endl;
 
	return 0;
}
开发者ID:mhossain7,项目名称:Quoting,代码行数:41,代码来源:PlethoraQuoting.cpp

示例12: deleteQuoteFields

void Board::setQuote(Quote& quote){
    deleteQuoteFields();
    
    const vector<QuoteLine>& lines = quote.getLines();
    for(vector<QuoteLine>::const_iterator itr = lines.begin(); itr != lines.end(); ++itr){
        mQuoteFields += new QuoteField( mGrid->getCell(itr->getIndices().front())->getCenter(),
                                        Rand::randInt(QUOTE_FIELD_NUM_DIVERS_MIN, QUOTE_FIELD_NUM_DIVERS_MAX),
                                       *itr );
    }
    
    mQuoteCurrent = &quote;
}
开发者ID:automat,项目名称:NEXT-Berlin-Stage-Identity,代码行数:12,代码来源:Board.cpp

示例13: quote_test

void quote_test()
{
   zmq::context_t context(1);
   zmq::socket_t pub(context, ZMQ_PUB);
   pub.bind("tcp://*:5556");

   Quote quote;
   zmq::message_t message;
   timestamp start;
   timestamp stop;
   timestamp diff;

   while (run)
   {
      double q_price = 150.0 + within(50) + within(100) / 100.0;
      uint64_t q_size = 30 + within(1000);
      uint8_t q_type = within(3);

      quote.set_price(q_price);
      quote.set_size(q_size);
      quote.set_type(wave::Quote_QuoteType(q_type));

      int size = quote.ByteSize();
      message.rebuild(size);

      start = timestamp::now();
      quote.SerializeToArray(message.data(), size);
      stop = timestamp::now();
      diff = stop - start;

      log::debug << "msg pack time = " << diff.total_usecs() << " us";

      if (pub.send(message) == -1)
         log::error << "error while sending: " << strerror(errno);

      sleep(1);
   }
}
开发者ID:ksergey,项目名称:playground,代码行数:38,代码来源:publisher0.cpp

示例14: print_debug

void print_debug(const Quote &q)
{
    q.debug();
}
开发者ID:jieniyimiao,项目名称:CppPrimer,代码行数:4,代码来源:main.cpp

示例15: add_item

 // copy version
 void add_item(Quote const& item)
 {
   cout << "basket::add_item(Quote const&)" << endl;
   items_.insert(std::shared_ptr<Quote>(
         item.clone()));
 }
开发者ID:keitee,项目名称:kb,代码行数:7,代码来源:cxx_case.cpp


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