注册 登录
编程论坛 VC++/MFC

error C2065: 'IFirst_ATL' : undeclared identifier

a7606508 发布于 2014-12-22 18:26, 821 次点击
// First.cpp : Implementation of CFirst
#include "stdafx.h"
#include "Simple_ATL.h"
#include "First.h"
#include <iostream.h>
/////////////////////////////////////////////////////////////////////////////
// CFirst


STDMETHODIMP CFirst::AddNumbers(long Num1, long Num2, long *ReturnVal)
{
    // TODO: Add your implementation code here
*ReturnVal=Num1+Num2;
    return S_OK;
}

#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL.h"
#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL_i.c"
void main(void)
{
    //声明Simple_ATL接口指针
    HRESULT hr;

    IFirst_ATL*IFirstATL=NULL;
    hr=CoInitialize(NULL);
    if(SUCCEEDED(hr))
    {
        hr=CoCreateInstance(CLSID_First,
                            NULL,
                            CLSCTX_INPROC_SERVER,
                            IID_IFirst_ATL,
                            (void* *)&IFirstATL);
        if(SUCCEEDED(hr))
        {
           long ReturnValue;
           IFirstATL->AddNumbers(5,7,&ReturnValue);
           cout<<"the answer for 5+7 is:"
               <<ReturnValue<<endl;
           IFirstATL->Release();
        }
        else
        {
            cout<<" cocreateinstance failed."<<endl;
    }
    }
    CoUninitialize();
}
//请问这个该怎样申明啊
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(24) : error C2065: 'IFirst_ATL' : undeclared identifier
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(24) : error C2065: 'IFirstATL' : undeclared identifier
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(24) : error C2106: '=' : left operand must be l-value
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(31) : error C2065: 'IID_IFirst_ATL' : undeclared identifier
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(36) : error C2227: left of '->AddNumbers' must point to class/struct/union
D:\MSDev98\MyProjects\Simple_ATL\First.cpp(39) : error C2227: left of '->Release' must point to class/struct/union
2 回复
#2
yuccn2014-12-24 12:10
#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL.h"
#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL_i.c"
这样写,你厉害啊

没有包含对应的头文件或依赖库吧
#3
a76065082014-12-24 12:38
以下是引用yuccn在2014-12-24 12:10:31的发言:

#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL.h"
#include "C:\Program Files\Microsoft Visual Studio\MyProjects\Simple_ATL\Simple_ATL_i.c"
这样写,你厉害啊

没有包含对应的头文件或依赖库吧

帮帮我该用那个头文件啊,我根据书上写的就是老不对
1