#include <iostream> #include "MoneyChanger.h" //Testing conceptional constance with 'mutable' keyword class testClass { /* make it mutable then callable by const fucntion. * It's better to make memberfunction called by this class * be const function. In that way you do not need mutable * funciton here. But some time you cannot modify it, * for example you are using prebuild library */ mutable MoneyChanger mc; public: // you must use a user define constructor, when you construct a const object. testClass() {} const long long test(double dollars) const{ return mc.howManyCombinations(dollars); } }; int main(int argc, const char * argv[]) { // this is conceptional constance instead of bit-wise constance. const testClass normalTestObj; std::cout << normalTestObj.test(100) << "\n"; // next line will be very fast, because last line do all computation // needed and save results into mutable member. std::cout << normalTestObj.test(10) << "\n"; return 0; }