English 中文(简体)
正在继承界面和 IUn已知, IDispatch 方法定义
原标题:inheriting interface & IUnknown ,IDispatch methods definitions

i need to inherit an interface with abstract methods , in VB/c# we simply override methods from our interface while there is no need to code for IUnknown or IDispatch methods

but in c++, after inheriting interface in class & overriding methods in interface, when i tried to instantiate derived class i am getting following error

error C2259:  Imyinterface  : cannot instantiate abstract class
1>          due to following members:



 HRESULT IUnknown::QueryInterface(const IID &,void **)  : is abstract
 ULONG IUnknown::AddRef(void)  : is abstract
  ULONG IUnknown::Release(void)  : is abstract 

因此,我需要推翻/取消 IUn known 和 IDispatch 方法, 如 adref, Release, Query Interface, invoke, gettyinfo 。

as they appears to be standard functions ,where can i get their code/definitions e.g.ATL or or any typelib? or any references where i can get code/examples of above methods

问题回答

_uery Interface :如果能够到达通过 GUID 所指定的界面,请在 eve /code> 参数中为界面设置一个指针;或者将 lese /code > 设置为 NULL 。返回相应的 HRESULT

AddRef :增加界面的引用数 。

releasure :减少界面的引用数 。

我建议先买一本关于COM的好书,然后再仔细研究。 旧版的< a href="https://rads. stackoverflow.com/amzn/click/com/ 1572313498" rel=“ nofollow noreferrer”>Inside Com (微软编程系列), 由 Dale Rogerson < /a > 编写, 是便宜的。 它确实有实例。 阅读亚马逊的评论, 以确定您是否愿意买下这本书 。

You need to override those methods and provide their definitions(in your derived class) and for all the functions declared pure virtual in your base class.
Unless you do so your derived class also acts as an abstract class and you cannot create any objects of it.

对于第二个问题,没有,我对这些方法的标准执行应该做些什么没有任何真正的好主意。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?