C++ 成员声明中不允许使用限定名称

C++ Qualified name is not allowed in member declaration

本文关键字:定名称 不允许 成员 声明 C++      更新时间:2023-10-16

我正在遵循 2012 年的 Fleeps 旧教程之一。我遇到了减速带,此错误:成员声明中不允许使用限定名称。我尝试更改SDK,在main.cpp文件中定义/声明类。这些都不起作用。这是我遇到错误的头文件。

#pragma once
#include <Windows.h>
#include "d3d9.h"
#include <ctime>
#include <iostream>
#define D3DHOOK_TEXTURES
#define MAX_MENU_ITEMS 6
#define WALLHACK 0
#define CUSTOM_CROSSHAIR 1
#define NO_RECOIL 2
#define UNLIM_AMMO 3
#define AUTO_FIRE 4
#define HIDE_MENU 5
class Hacks {
public:
    int m_Stride;
    void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont);
    void Hacks::InitializeMenuItems();
    void Hacks::DrawText(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color);
    void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice);
    void Hacks::DrawFilledRectangle(int x, int y, int w, int h, D3DCOLOR Color, IDirect3DDevice9 *d3dDevice);
    void Hacks::DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR Color, IDirect3DDevice9 *d3dDevice);
    void Hacks::KeyboardInput();
    LPDIRECT3DTEXTURE9 texRed;
    LPDIRECT3DTEXTURE9 texGreen;
    LPDIRECT3DTEXTURE9 texBlue;
    LPDIRECT3DTEXTURE9 texWhite;
    D3DVIEWPORT9 ViewPort;
    LPD3DXFONT Font;
    struct d3dMenuHack {
        bool on;
        std::string name;
    };
    d3dMenuHack hack[MAX_MENU_ITEMS];
};

当我宣布"无效黑客::"时,错误正在发生。功能。有什么建议吗?

也许 nikau6 的答案乍一看并不那么清楚,因为代码似乎与 OP 中的代码相同。

因此,解决方案是从所有声明中删除Hacks::

在Visual Studio 2019中构建传统的Direct Show过滤器时,我必须将Conformance Mode设置为"否"。这允许代码不符合标准/宽容-

以上是几个人说的不好的做法。但是对于遗留代码,通常不适合(或不可能(使其遵循最佳实践。

没有要在成员声明中使用的限定名称。你的书中使用了哪个编译器?

class Hacks {
    public:
        int m_Stride;
        void CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont);
        void InitializeMenuItems();
        void DrawText(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color);
        void DrawMenu(IDirect3DDevice9 *d3dDevice);
        void DrawFilledRectangle(int x, int y, int w, int h, D3DCOLOR Color, IDirect3DDevice9 *d3dDevice);
        void DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR Color, IDirect3DDevice9 *d3dDevice);
        void KeyboardInput();
        LPDIRECT3DTEXTURE9 texRed;
        LPDIRECT3DTEXTURE9 texGreen;
        LPDIRECT3DTEXTURE9 texBlue;
        LPDIRECT3DTEXTURE9 texWhite;
        D3DVIEWPORT9 ViewPort;
        LPD3DXFONT Font;
        struct d3dMenuHack {
            bool on;
            std::string name;
        };
        d3dMenuHack hack[MAX_MENU_ITEMS];
    };