gpt4 book ai didi

C++ CImage 不完整的类型是不允许的

转载 作者:行者123 更新时间:2023-11-28 00:04:08 25 4
gpt4 key购买 nike

我得到不完整的类型不允许使用 CImage 图像;
我用过这个:

出了什么问题?我以前从未叫过课。

using namespace std;
class CImage;


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

最佳答案

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

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


来自MSDN CImage class ducumentation :

When you create a project using CImage, you must define CString before you include atlimage.h. If your project uses ATL without MFC, include atlstr.h before you include atlimage.h. If your project uses MFC (or if it is an ATL project with MFC support), include afxstr.h before you include atlimage.h.

Likewise, you must include atlimage.h before you include atlimpl.cpp. To accomplish this easily, include atlimage.h in your stdafx.h.

关于C++ CImage 不完整的类型是不允许的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36712445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com