title: How to pass a member function to a base class contructor?
body: <p>I have a class structure that i want to use and i want to use a function of a derived class to be passed as a constructor argument to the base class. I cannot find the right syntax for it (new to C :))</p>
  
  <p>This is the base class that i use and it has a constructor with a callback function:</p>
  
  <pre><code>class SPortSensor {
          public:
              SPortSensor(sensorData (*pCallback)(SPortSensor*));
              sensorData getValue();
          private:
              sensorData (*getData)(SPortSensor*);
      };
  </code></pre>
  
  <p>This is the derived class that implements the callback function within the class (pCallback) so it has a different constructor and a member function that needs to be passed to the base class constructor:</p>
  
  <pre><code>    class SimpleSensor : public SPortSensor {
          public: 
              SimpleSensor(int id);
              long value;
          private:
              int _id;
              sensorData pCallback(SPortSensor*);
      };
  </code></pre>
  
  <p>This header compiles fine. The only error i am seeing is in the implementation of the SimpleSensor constructor. I cannot find the right syntax for this:</p>
  
  <pre><code>sensorData SimpleSensor::pCallback(SPortSensor* sensor) {
     ...
  }
  
  SimpleSensor::SimpleSensor(int id) : SPortSensor(pCallback) {
    _id = id;
  }
  </code></pre>
  
  <p>Googling this issue didn't help that much since i probably don't use the right search words and don't understand enough of c++ (i am a C# guy).</p>