Dependency injection (Design pattern)

As the name of this creational design pattern already shows dependencies are getting injected (as parameter) instead of creating them internally.

class IAudioControl {};
class AudioControl : public IAudioControl {};
 
class OfflineMediaPlayer
{
public:
  // Constructor without dependency injection
  OfflineMediaPlayer() { m_AudioControl = new AudioControl(); }
  ~OfflineMediaPlayer() { delete m_AudioControl; }
private:
  IAudioControl* m_AudioControl;
};

class OnlineMediaPlayer
{
public:
  // Constructor with dependency injection
  OnlineMediaPlayer(IAudioControl* audioControl)
    : m_AudioControl(audioControl) {}
private:
  IAudioControl* m_AudioControl;
};

int main()
{
  {
    OfflineMediaPlayer offlineMediaPlayer;
  }

  {
    AudioControl audioControl;
    OnlineMediaPlayer onlineMediaPlayer(&audioControl);
  }

  return 0;
}