我用记录集对象m_Recordset->Open(str1.AllocSysString(),                

      m_pConnection.GetInterfacePtr(),

adOpenDynamic,

adLockOptimistic,

adCmdText);
为什么调试时说left of '.GetInterfacePtr' must have class/struct/union type
                        m_pConnection' : undeclared identifier
我的_connectionptr对象在myapp的public中定义了为什么不行。
谢谢。

解决方案 »

  1.   

    ((myapp *)afxGetApp())->m_pConnection.GetInterfacePtr(),
      

  2.   

    麻烦说清楚点,你这段代码是在myapp中的吗?
      

  3.   

    我照楼上说的做了后但是他说 'MyApp' : undeclared identifier
      

  4.   

    ....................他说得myapp表示你自己定义的app。就是你定义_ConnectionPtr的地方。
    另外,你的 m_pConnection在哪里定义的,在这个错误之前有没有说 m_pConnection未定义的错误。
      

  5.   

    我看人家例子是用extern 声明 _connectionptr 对象。是不是 我也要用它生明呢?
      

  6.   

    m_pConnection.GetInterfacePtr(),应该是 m_pConnection->GetInterfacePtr(),
      

  7.   

    m_pConnection是一个智能指针类的实例
      

  8.   

    我知道
    但是为什么不行
    用extern声明后直接就是系统错误,但是我看书上的很多例子都是用extren声名的但是为什么 他们的都没有问题
      

  9.   

    你的m_pConnection到底是在哪里定义的?extern C***App theApp;m_Recordset->Open(str1.AllocSysString(),                      theApp.m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
      

  10.   

    就是这样写的但是抱错。m_pConnection 在myApp的public中写着
      

  11.   

    To doon(东方) :如果是_ConnectionPtr的话,就应该用.不是用->
    To 楼主:给出你定义的地方吧。你的...App.h/和...App.cpp