Login  Register

Re: Error in compiling of QuantLib examples

Posted by Luigi Ballabio on Jan 27, 2017; 10:30am
URL: http://quantlib.414.s1.nabble.com/Error-in-compiling-of-QuantLib-examples-tp17991p18036.html

Your visitor should work as you've written it.  Try adding some other kind of cash flow, such as FixedRateCoupon.

Luigi




On Thu, Jan 26, 2017 at 10:55 PM Ioannis Rigopoulos <[hidden email]> wrote:

You 're welcome Ziegele,

1) No, because CashFlow is abstract and emplace_back relies on the existence of a constructor.

2) I am not familiar with the visitor pattern, but I suspect you could achieve this by removing all the visit overloads except the void visit( CashFlow & c ) one.

Then you modify the code inside as follows:

void visit( CashFlow & c ) {

  cashFlowSum += p->amount();

    if( SimpleCashFlow * p = dynamic_cast<CashFlow *>( &c ) ) {

	simpleCashFlowSum += p->amount();

    }

    else if( Redemption * p = dynamic_cast<Redemption *>( &c ) ) {

	redemptionSum += p->amount();

    }

    else if( AmortizingPayment * p = dynamic_cast<AmortizingPayment *>( &c ) ) {

	amortizingPaymentSum += p->amount();

    }

}


Let me know if this works

Cheers

Yannis

On 26.01.2017 20:42, ziegele wrote:
Thanks Yannis!

1 last question: is there a way to emplace_back a CashFlow shared_ptr? It
shows that it's purely virtual, which only serves as an interface:

<http://quantlib.10058.n7.nabble.com/file/n18024/cashFlow.jpg> 

Is there anyway of generating a non-zero report for "all other cash flows"
part?

<http://quantlib.10058.n7.nabble.com/file/n18024/output.jpg> 

Thanks,
ziegele



--
View this message in context: http://quantlib.10058.n7.nabble.com/Error-in-compiling-of-QuantLib-examples-tp17991p18024.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users





Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users