6

I am following one of Fleeps old tutorials from 2012. I have encountered a speedbump, this error: qualified name is not allowed in member declaration. I have tried changing the SDK, defining/declaring the class in the main.cpp file. None of this worked. This is my header file i am encountering the error in.

#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];
};

The error is ocouring when i am declaring the "void Hacks::"... functions. Any suggestions?

Lukas Knudsen
  • 197
  • 2
  • 3
  • 14
  • 7
    Remove these `Hacks::`s. – songyuanyao Jan 15 '18 at 01:07
  • 1
    *I have tried changing the SDK, defining/declaring the class in the main.cpp file. None of this worked* -- Which goes to show that following a tutorial that doesn't teach C++ programming is a time-waster. No reputable C++ book would have shown a class coded this way with this error. – PaulMcKenzie Jan 15 '18 at 01:31
  • @songyuanyao Thanks. This excelled this problem, and I can now compile the project. Although when I build it, it gives me this error “Error LNK2001: unresolved external symbol __vsnprintf” – Lukas Knudsen Jan 15 '18 at 10:06
  • 1
    You are getting the link error because the legacy DirectX SDK is not fully compatible with VS 2015 or VS 2017. See [Where’s DXERR.LIB?](https://blogs.msdn.microsoft.com/chuckw/2012/04/24/wheres-dxerr-lib/). – Chuck Walbourn Jan 16 '18 at 17:14
  • 1
    There's no reason to spend time learning Direct3 9 at this point. Look at DirectX 11. See [this post](https://blogs.msdn.microsoft.com/chuckw/2011/07/11/getting-started-with-direct3d-11/). An old book/tutorial on Direct3D 9 is also quite likely to be using much older C++ coding style rather than the modern C++11/C++14 language. – Chuck Walbourn Jan 16 '18 at 17:18

3 Answers3

14

Maybe nikau6's answer is not so clear at first sight because the code seems identical to the one in the OP.

So, the solution is to remove Hacks:: from all your declarations

Francesco
  • 523
  • 4
  • 25
3

While building a legacy Direct Show filter in Visual Studio 2019 I had to set Conformance Mode to No. This allows the code to not conform to the standard /permissive-

The above is poor practice as stated by several people. But with legacy code it's often the not appropriate(or possible) to make it follow best practices.

elmsfu
  • 229
  • 2
  • 3
  • Thanks for the hint! I also came across queer legacy code when compiling headers from Windows SDK 8.1 with Visual Studio 2017 - there are such places in ``, ``, ``, etc. – AntonK Jul 07 '20 at 23:17
1

No qualified names to use in member declarations. Which compiler is used in your book ?

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];
    };
nikau6
  • 922
  • 9
  • 16