本文整理汇总了C++中Money::value方法的典型用法代码示例。如果您正苦于以下问题:C++ Money::value方法的具体用法?C++ Money::value怎么用?C++ Money::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money
的用法示例。
在下文中一共展示了Money::value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Decimal operator/(const Money& m1, const Money& m2) {
if (m1.currency() == m2.currency()) {
return m1.value()/m2.value();
} else if (Money::conversionType == Money::BaseCurrencyConversion) {
Money tmp1 = m1;
convertToBase(tmp1);
Money tmp2 = m2;
convertToBase(tmp2);
return tmp1/tmp2;
} else if (Money::conversionType == Money::AutomatedConversion) {
Money tmp = m2;
convertTo(tmp, m1.currency());
return m1/tmp;
} else {
QL_FAIL("currency mismatch and no conversion specified");
}
}
示例2: close_enough
bool close_enough(const Money& m1, const Money& m2, Size n) {
if (m1.currency() == m2.currency()) {
return close_enough(m1.value(),m2.value(),n);
} else if (Money::conversionType == Money::BaseCurrencyConversion) {
Money tmp1 = m1;
convertToBase(tmp1);
Money tmp2 = m2;
convertToBase(tmp2);
return close_enough(tmp1,tmp2,n);
} else if (Money::conversionType == Money::AutomatedConversion) {
Money tmp = m2;
convertTo(tmp, m1.currency());
return close_enough(m1,tmp,n);
} else {
QL_FAIL("currency mismatch and no conversion specified");
}
}
示例3: exchange
Money ExchangeRate::exchange(const Money& amount) const {
switch (type_) {
case Direct:
if (amount.currency() == source_)
return Money(amount.value()*rate_, target_);
else if (amount.currency() == target_)
return Money(amount.value()/rate_, source_);
else
QL_FAIL("exchange rate not applicable");
case Derived:
if (amount.currency() == rateChain_.first->source() ||
amount.currency() == rateChain_.first->target())
return rateChain_.second->exchange(
rateChain_.first->exchange(amount));
else if (amount.currency() == rateChain_.second->source() ||
amount.currency() == rateChain_.second->target())
return rateChain_.first->exchange(
rateChain_.second->exchange(amount));
else
QL_FAIL("exchange rate not applicable");
default:
QL_FAIL("unknown exchange-rate type");
}
}