Re: STDMETHOD vs STDMETHODIMP
Jay Hamilton <jayhamiltoniv@gmail.com> wrote:
I'm looking for thoughts about a base class that implements an
interface in a reuseable header file. Are there any demons hiding out
there if the reuseable uses STDMETHODIMP for all of its fxns, i.e.
there is no fxn prototype, just implementation in the header? Should
STDMETHOD be used in this case to pick up the virtual declaration?
The only difference between STDMETHOD and STDMETHODIMP is that the
former includes 'virtual' keyword in its expansion while the later
doesn't. Thus STDMETHOD must be used for declaring new methods (e.g. in
the interface definition produced by MIDL compiler), while STDMETHODIMP
must be used when implementing the method in .cpp file. Either can be
used when declaring a method in your class derived from the interface
('virtual' keyword is optional there). Personally, I use STDMETHODIMP
here, so the declaration in the header looks more like the definition in
the .cpp file. You would only ever need to use STDMETHOD when defining
an interface in C++ by hand, without IDL file, and it's not clear why
one would want to do that.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925