本文介绍了如何获取模板化的WTL类对象C ++的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一些C ++代码,这让我感到困惑.

有一个这样声明的类.

I inherited some C++ code and it has me stumped.

Have a class declared like so.

class CIENavigator :  public CWTLAxControl<CIENavigator,iWebBrowser2>
{
public:
...

Instance like so
CIENavigator CIE;
CIENavigator * pCIE = &CIE;



获取此编译错误



Gets this compile error

1>.\IENavigator.cpp(446) : error C2440: 'initializing' : cannot convert from 'IWebBrowser2 **' to 'CIENavigator *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast



尽管CIE被声明为CIENavigator,但它认为& CIE的类型为IWebBrowser2 **

如果我这样强制施放:



Although CIE is declared as CIENavigator, it thinks the type of &CIE to be IWebBrowser2 **

If I force the cast like so:

CIENavigator CIE;
CIENavigator * pCIE = (CIENavigator *) &CIE;


它可以编译,但是指针确实是错误的指针.

我注意到类名出现在其自身的声明中,但我不知道其含义是什么.
我不了解Class模板.

如何获取正确的CIENavigator对象(CIE)地址?


It compiles, but the pointer is indeed the wrong pointer.

I note the class name appears in the declaration of itself, but I don''t know what the significance of that is.
I''m not up on Class templates.

How do I get the right CIENavigator object (CIE) address?

推荐答案


这篇关于如何获取模板化的WTL类对象C ++的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:16