Result class dependency
- by Stefano Borini
I have an object containing the results of a computation. This computation is performed in a function which accepts an input object and returns the result object.
The result object has a print method. This print method must print out the results, but in order to perform this operation I need the original input object. I cannot pass the input object at printing because it would violate the signature of the print function. One solution I am using right now is to have the result object hold a pointer to the original input object, but I don't like this dependency between the two, because the input object is mutable.
How would you design for such case ?