求助:关于IDispatch接口的ATL默认实现IDispatchImpl模板,其中一行代码不理解。

huyiwatching 2009-10-25 11:52:12
IDispatch接口的默认实现为IDispatchImpl, 在atlcom.h中,如下代码片断不是很理解:


template <class T, const IID* piid, const GUID* plibid, WORD wMajor, WORD wMinor, class tihclass>
typename IDispatchImpl<T, piid, plibid, wMajor, wMinor, tihclass>::_tihclass
IDispatchImpl<T, piid, plibid, wMajor, wMinor, tihclass>::_tih =
{piid, plibid, wMajor, wMinor, NULL, 0, NULL, 0};

::_tih ={piid, plibid, wMajor, wMinor, NULL, 0, NULL, 0}; //这一行是什么意思? 我没有发现tihclass代表的类中有“=”运算符重载函数,为什么就可以直接用“=”号连接起来? 不知道是什么语法规则。

谢谢!
...全文
81 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huyiwatching 2009-10-26
  • 打赏
  • 举报
回复
是的,是的。 谢谢!
butwang 2009-10-26
  • 打赏
  • 举报
回复
::_tih ={piid, plibid, wMajor, wMinor, NULL, 0, NULL, 0}; //这一行是什么意思? 我没有发现tihclass代表的类中有“=”运算符重载函数,为什么就可以直接用“=”号连接起来? 不知道是什么语法规则。

这是聚合的初始化方式

聚合定义为:
数组
没有以下内容的类、结构和联合:
构造函数
私有或受保护的成员
基类
虚函数

比如
数组
int rgiArray[10] = { 9, 8, 4, 6, 5, 6, 3, 5, 6, 11 };

结构
struct RCPrompt
{
short nRow;
short nCol;
char *szPrompt;
};
int main()
{
RCPrompt rcContinueYN = { 24, 0, "Continue (Y/N?)" };
}


class RCPrompt
{
public:
short nRow;
short nCol;
char *szPrompt;
};
int main()
{
RCPrompt rcContinueYN = { 24, 0, "Continue (Y/N?)" };
}

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧