title: What are the possible ways to override a function in Magento2?
body: <p>How can I override a constructor in Magento2? I want to override the <code>execute</code> function of <code>Magento\Customer\Controller\Account\LoginPost</code> class. And while doing that I want to use <code>Magento\Customer\Api\Data\GroupInterface</code> for <strong>changing customers group</strong>. I can use <code>objectManager</code> but that is not recommended. So what are the other ways?</p>