// ********** DecoratorDemo.cpp ********** #include #include using namespace std; class CoreIF { public: virtual void standardOperation() = 0; }; class Core : public CoreIF { public: void standardOperation() {} }; class Decorator : public CoreIF { private: CoreIF* core; public: Decorator(CoreIF* core) { this->core = core; } void standardOperation() { core->standardOperation(); } }; class EmbellishmentA : public Decorator { public: EmbellishmentA(CoreIF* core) : Decorator(core) {} void standardOperation() { Decorator::standardOperation(); // plus extra A } }; class EmbellishmentB : public Decorator { public: EmbellishmentB(CoreIF* core) : Decorator(core) {} void standardOperation() { Decorator::standardOperation(); // plus extra B } }; const int MAX = 100000; int main() { hrtime_t t1 = gethrtime(); for (int i=0; istandardOperation(); } hrtime_t t2 = gethrtime(); cout << (t2-t1)/1000000 << " "; return 1; }