--- /dev/null
+#include "Harl.h"
+#include <string>
+#include <map>
+#include <iostream>
+
+Harl::Harl()
+{
+ m_levels[0] = "debug";
+ m_speech[0] = &Harl::debug;
+ m_levels[1] = "info";
+ m_speech[1] = &Harl::info;
+ m_levels[2] = "warning";
+ m_speech[2] = &Harl::warning;
+ m_levels[3] = "error";
+ m_speech[3] = &Harl::error;
+}
+
+Harl::Harl(const Harl &harl)
+{
+ *this = harl;
+}
+
+Harl::~Harl()
+{
+}
+
+Harl &Harl::operator=(const Harl &harl)
+{
+ m_levels[0] = harl.m_levels[0];
+ m_speech[0] = harl.m_speech[0];
+ m_levels[1] = harl.m_levels[1];
+ m_speech[1] = harl.m_speech[1];
+ m_levels[2] = harl.m_levels[2];
+ m_speech[2] = harl.m_speech[2];
+ m_levels[3] = harl.m_levels[3];
+ m_speech[3] = harl.m_speech[3];
+ return (*this);
+}
+
+void Harl::complain(std::string level)
+{
+ void (Harl::*selected)(void);
+
+ selected = NULL;
+ for (size_t i(0); i < 4; ++i)
+ if (m_levels[i] == level)
+ selected = m_speech[i];
+ if (selected)
+ (this->*selected)();
+ else
+ std::cout << "Harl does not know this level.\n";
+}
+
+void Harl::debug(void)
+{
+ std::cout << "I love having extra bacon for my "
+ "7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!\n";
+}
+
+void Harl::info(void)
+{
+ std::cout << "I cannot believe adding extra bacon costs more money. "
+ "You didn’t put enough bacon in my burger! "
+ "If you did, I wouldn’t be asking for more!\n";
+}
+
+void Harl::warning(void)
+{
+ std::cout << "I think I deserve to have some extra bacon for free. "
+ "I’ve been coming for ears whereas you started working here since last month.\n";
+}
+
+void Harl::error(void)
+{
+ std::cout << "This is unacceptable! I want to speak to the manager now.\n";
+}
--- /dev/null
+#ifndef HARL_H
+# define HARL_H
+
+# include <string>
+
+class Harl
+{
+ private:
+ void debug(void);
+ void info(void);
+ void warning(void);
+ void error(void);
+
+ void (Harl::*m_speech[4])(void);
+ std::string m_levels[4];
+
+ public:
+ Harl();
+ Harl(const Harl &harl);
+ ~Harl();
+
+ Harl &operator=(const Harl &harl);
+ void complain(std::string level);
+};
+
+#endif // HARL_H
--- /dev/null
+#include "Harl.h"
+
+int main(void)
+{
+ Harl harl;
+
+ harl.complain("info");
+ harl.complain("debug");
+ harl.complain("warning");
+ harl.complain("error");
+ harl.complain("debug");
+ harl.complain("info");
+ harl.complain("error");
+ return (0);
+}