Thread: Memoisation
View Single Post
  #8 (permalink)  
Old 06-04-2012, 06:30 AM
Michael Le Barbier Grünewald
Guest
 
Posts: n/a
Default Re: Memoisation

Hello Qi,

On Friday, June 1, 2012 9:52:43 AM UTC+2, Qi wrote:
> Maybe you can dedicate your virtual function to sister
> in a multiple inheritance?
> http://www.parashift.com/c++-faq-lit...html#faq-25.10


I do not really understand what you mean here...

I ``discovered'' the `delegate to sister' idiom for a few weeks
and used this in the following manner:

A is an ABS, A': virtual public A implements a concrete A.
P : virtual public A implements algorithms involving A,
and to get a concrete P we just need to let

P': public P, public A'

In this example using `delegate to sister' can be avoided by
letting P access A through a reference and this is probably
the most idiomatic way to go. Just out of curiosity,
in which sort of situations can be `the delegate to sister'
successfully used?

> > 2. reallyEval() is typically a private member, so
> > we need to let memoise be a friend of Btype: if memoise
> > can only be used on leaves, this is quite a lot of work.

>
> You can use a global accessor function to
> access reallyEval(), and let that function
> be Btypes' friend. Then all other classes
> use that accessor function.


Thank you for the tip, I did not know about it!
Reply With Quote