#include <string>
#include <iostream>
class Head{
public :
std::string description = "Head";
virtual std::string get_description( ){return description;}
};
class Decorator:public Head{
public:
virtual std::string get_description()=0;
};
class Hair:public Decorator
{
public :
Head *base;
std::string get_description(){return "Hair, " + base->get_description();};
Hair(Head* h):base(h){};
};
class Noise:public Decorator
{
public:
Head *base;
Noise(Head* h):base(h){};
std::string get_description(){return "Noise, " + base->get_description();}
};
int main(){
Head *head = new Head();
head = new Hair(head);
head = new Noise(head);
std::cout << head->get_description() << std::endl;
return 0;
}
|