简体   繁体   中英

How to get address of templated WTL class object 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

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;

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?

CWTLAxControl可能有一个重载的operator& ,以避免使用Boost.AddressOf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM