title: QT / c++ best way to call a method of parent
body: <p>I need to control file I/O using a method (called write) in class A.  A then instantes another class B (not based on A), which needs to write to the file, by calling A.write().</p>
  
  <p>What is the best way to achieve this?  </p>
  
  <p>Should I pass the Class.functionname (A.write) as a parameter to B.sometfunction for callback?</p>
  
  <p>Should I make A.write a slot, and allow B to emit a signal?</p>
  
  <p>Is there a better way?  (I'm using QT 5 with C++ )</p>
  
  <hr>
  
  <p>Ok, some more info to help explain:
  A is a collection of threads, each being a TcpSocket (console session from client)
  B is my logger class, and is a singleton pattern.
  A threads sometimes have to log a message to a file, which B formats and writes to the file using a mutex.
  These same (formatted) messages should be written to the console (unique socket per A thread, so cannot be a static method).
  So A.something calls B.write (to file), and then B.write needs to call A.write (to console).</p>