C++ Function pointers vs Subclasses
<p>I am in a position to choose between function pointers and subclassed objects. To make it clear, say I have to notify some object of some action (a timer for example); refer to the following two choices (a very basic code for demo purposes):</p>

<p><strong>Version 1</strong></p>

<pre><code>typedef void TimerCallback(void *args);
class Timer{
public:
  Timer();
  ~Timer();
  void schedule(TimerCallback *callback, void *args, long timeout)=0;
  void cancel();
};
</code></pre>

<p><strong>Version 2</strong></p>

<pre><code>class TimerTask{
  public:
    TimerTask();
    virtual ~TimerTask();
    void timedout()=0;
};
class Timer{
  public:
    Timer();
    virtual ~Timer();
    void schedule(TimerTask *callback, long timeout)=0;
    void cancel();
};
</code></pre>

<p>which one is the standard C++ way and which one is efficient? Please let me know if you have any other suggestions in this regard.</p>

<p>Please let me know if I am not clear in this regard.</p>

<p>Thanks</p>
