按值传递指针

Luk*_*uke 1 c++ pass-by-reference pass-by-pointer

具有以下功能:

virtual HRESULT GetMediaType(
  int iPosition,
  CMediaType *pMediaType
);
Run Code Online (Sandbox Code Playgroud)

如何调用它以便通过引用传递pMediaType并保留对方法中对象所做的所有操作?

SKi*_*SKi 5

因为您将对象作为指针提供给函数,所以保留了对方法中对象所做的所有操作.

您可以通过以下方式调用它:

CMediaType pMediaType;
GetMediaType( 0, &pMediaType );
Run Code Online (Sandbox Code Playgroud)