本文整理汇总了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;
}
示例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;
}
示例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
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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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 = "e;
}
示例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);
}
}
示例14: print_debug
void print_debug(const Quote &q)
{
q.debug();
}
示例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()));
}