class Person;
class Command {
private:
Person * object;
//what is this? - a functor?...
void (Person::*method)();
public:
Command(Person *a, void(Person::*m() = 0): object(a),method(m) {}
void execute() { (object->*method(); }
};
// defining class Person here
class Person {
private:
string name;
Command cmd;
public:
Person(string a, Command c): name(a),cmd(c) {}
void talk();
void listen();
};
I was wondering what line 6 here means? Is that a way of defining a function or a functor? Also where does this type of function def appear and tends to be used? I found this example Under "Design Patterns" within Object Oriented Programming - this approach type is called Behavioural Command Pattern.