Decorator
#include
using namespace std;
class Person
{
public:
void MakeStatement(string szStatement){ cout << szStatement;}
};
/*
The decorator class.
NOTE: I believe that the decorator should
not take a person as a constructor arg but have a
setPerson function. This would enable one decorator
object to "decorate" or extend multiple person objects.
*/
class RelativistDecorator
{
public:
RelativistDecorator(Person* person) : m_pPerson(person){}
void MakeStatement(string szStatement){ cout << "In my opinon " << szStatement; }
Person* m_pPerson;
};
int main()
{
cout << "Class:main, Method:main\n";
Person aPerson;
aPerson.MakeStatement("Design patterns are useless");
cout << endl;
RelativistDecorator rd(&aPerson);
rd.MakeStatement("Design patterns are useless");
cout << endl;
}