gpt4 book ai didi

c++ - 包含标题会导致错误

转载 作者:太空狗 更新时间:2023-10-29 23:46:51 26 4
gpt4 key购买 nike

出于某种原因,我在包含自己的头文件后遇到多个错误,该头文件具有简单的类定义。这是代码:

#define WIN32_LEAN_AND_MEAN 
#include "windows.h"
//#include "CInt.h" <--- i get multiple errors once i activate this line

HINSTANCE hInst;
HWND wndHandle;

bool initWindow(HINSTANCE hInstance);

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
if (!initWindow(hInstance)) return false;

MSG msg;
ZeroMemory(&msg, sizeof(msg));

while(true)
{
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

if(msg.message == WM_QUIT) break;
}

return msg.wParam;
}

bool initWindow(HINSTANCE hInstance )
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
wcex.lpszMenuName = 0L;
wcex.lpszClassName = L"MOVEENGINE";
wcex.hIconSm = 0;

RegisterClassEx(&wcex);

wndHandle = CreateWindow(L"MOVEENGINE", L"MOVE ENGINE", WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE, 0, 0, 1920, 1080, NULL, NULL, hInstance, NULL);

if (!wndHandle) return false;

ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);

return true;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int iVirtKey = static_cast<int>(wParam);

switch (message)
{
case WM_KEYDOWN:
switch(iVirtKey)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
return 0;

case WM_DESTROY:
PostQuitMessage(0);
break;
}

return DefWindowProc(hWnd, message, wParam, lParam);
}

还有 CInt.h 的代码:

class CInt
{
public:
int k;

CDirect3DDevice(int x):k(x){};
}

那么我的代码有什么问题呢? (我使用 Visual Studio 2010)

最佳答案

您的 .h 文件中类定义后缺少分号。

关于c++ - 包含标题会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8640857/

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