Thread: Memoisation
View Single Post
  #1 (permalink)  
Old 05-31-2012, 06:23 AM
Michael Le Barbier Grünewald
Guest
 
Posts: n/a
Default Memoisation

Dear Group,

I am trying to implement memoisation in C++ for abstract classes such that:

I have an abstract class A with a public `int eval()' method delegating itswork to the private purely virtual, customisable, `int reallyEval()' method.

Now, let's say that I have a few concrete classes B1, .., Bn derived from A..

Is this possible to add memoisation to B1...Bn by introducing a class C andletting B inherit from C instead of A?

If not, what is the best way to add memoisation?

A possibility would be to edit A and add a level of indirection in the `eval' chain by adding a private customisable `memoisedEval' method whose default version would just call `reallyEval' and the version in a class `MemoisedA' would implement actual memoisation.

This is as close as I could get of my goal, but this involves edition of A.Is this avoidable?


Thank you for your insights!
Michael
Reply With Quote