title: How does C++ knows child class calls a parent method?
body: <p>I don't know how to summarize my question so couldn't find an answer on Google.</p>
  
  <p>When overriding a parent method,</p>
  
  <pre><code>void Child::method(){
      //stuff
      Parent::method();
  }
  </code></pre>
  
  <p>Works perfectly. But the parent method requires the information from the Child class instance to work properly, which is not given as arguments. So my question is, does C++ have a mechanism to let the Parent know which instance of a Child class calls a Parent method, like <strong>without</strong> doing <code>Parent::method(this)</code> ?</p>
  
  <p>The thing that makes me think this is, if you do something like this,</p>
  
  <pre><code>int main(){
      SomeParentClass::someMethod();
  }
  </code></pre>
  
  <p>It gives: <strong>error: call to non-static member function without an object argument.</strong> So the compiler needs to know the instance, which was not also given in the child class. But did not raise an error so it must have known the instance.</p>
  
  <p><strong>Edit:</strong> I added the Qt tag because I am experimenting on a Qt class. So that I can give an example if needed.</p>
  
  <p><strong>Edit2:</strong></p>
  
  <p>devicedialog.h</p>
  
  <pre><code>class DeviceDialog : public QDialog
  {
      Q_OBJECT
  
  public:
      explicit DeviceDialog(QWidget *parent = nullptr);
      int exec() override;
      ~DeviceDialog() override;
  }
  </code></pre>
  
  <p>devicedialog.cpp</p>
  
  <pre><code>int DeviceDialog::exec(){
      // My code.
      return QDialog::exec();
  }
  </code></pre>
  
  <p><code>exec()</code> function activates and shows a QDialog on the screen. However, that way it is called, it seems like the parent method has no way of knowing which dialog to show (no parameters passed). The only knowledge could be the identity of the instance calling it. I am just asking if this knowledge transferred to the method in the background.</p>