【问题标题】:C++ CImage incomplete type is not alloweed不允许 C++ CImage 不完整类型
【发布时间】:2016-04-26 19:24:57
【问题描述】:

CImage 图像不允许输入不完整类型;
我用这个:

出了什么问题?我以前从来没有叫过课。

using namespace std;
class CImage;


myfunction(hbitmap bmp)
{
    CImage image;
    image.Attach(bmp);
    image.Save("filename.jpg");
}

【问题讨论】:

    标签: c++ mfc


    【解决方案1】:

    class CImage; 是一个前向声明,它告诉编译器存在一个名为CImage 的类,但不知道该类是如何定义的(因此类型不完整)。

    您需要包含定义CImage 类的头文件。 试试#include <atlimage.h> 而不是class CImage;


    来自MSDN CImage class ducumentation

    当您使用CImage 创建项目时,您必须在包含atlimage.h 之前定义CString。如果您的项目使用没有 MFC 的 ATL,请在包含 atlimage.h 之前包含 atlstr.h。如果您的项目使用 MFC(或者如果它是支持 MFC 的 ATL 项目),请在包含 atlimage.h 之前包含 afxstr.h

    同样,您必须先包含atlimage.h,然后再包含atlimpl.cpp。要轻松完成此操作,请将atlimage.h 包含在您的stdafx.h 中。

    【讨论】:

    • #include #include #include 像这样?
    • @MichaelC #include #include
    • 我在我的一个函数中使用它,我得到这个严重代码描述项目文件行抑制状态错误 C2079 'image' 使用未定义的类 'GetScreenShot::CImage' dev_heading_loc_reader c:\users\ myoth\documents\visual studio 2015\projects\visual studio stuff\dev_heading_loc_reader\dev_heading_loc_reader\stringcapture.cpp 192
    • @MichaelC 请帮助我们为您提供帮助并提供Minimal, Complete, and Verifiable example,没有它就很难说出了什么问题。
    猜你喜欢
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 2019-10-08
    • 2011-05-13
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    相关资源
    最近更新 更多