2017-06-05 130 views
-2

我有一個文件「HSlider.h」它使用「Draw.h」,在那裏我定義了我的函數來使用它們。 但編譯器說我沒有定義他們(識別器未找到)。我搜索論壇尋找類似的錯誤,但它沒有幫助。標識符找不到.C3861

我在VS 2015 Communty工作。

ERROR實施例: 錯誤C3861 DrawGUIBox:標識符沒有找到 Try2 C:\用戶\ LEL \文件\視覺工作室2015 \項目\ try2 \ try2 \ hslider.h 50 。

HSlider.h

#include <string> 
#include <iostream> 
#include <map> 
#include <iterator> 
#include <conio.h> 
#include "Offsets.h" 

#include "Draw.h" 
using namespace std; 


class Button 
{ 
public: 
    void Init(float _x, float _y, float _w, float _h, int _r, int _g, int _b, int _a, int _rr, int _gg, int _bb, int _aa,int _onr,int _ong,int _onb) 
    { 
     x = _x; 
     y = _y; 
     w = _w; 
     h = _h; 
     r = _r; 
     g = _g; 
     b = _b; 
     a = _a; 
     rr = _rr; 
     gg = _gg; 
     bb = _bb; 
     aa = _aa; 
     onr = _onr; 
     onb = _onb; 
     ong = _ong; 

    } 
    void Move(float _x, float _y) 
    { 
     x = _x; 
     y = _y; 
    } 
    void Update(int _bindb) 
    { 
     BindB = _bindb; 
     DrawGUIBox(x, y, w, h, r, g, b, a, rr, gg, bb, aa); 
     POINT p; 
     GetCursorPos(&p); 

     if ((p.x > x&&p.x<x + w&&p.y>y&&p.y < y + h)) 
     { 
      if ((GetAsyncKeyState(VK_LBUTTON)&1)) 
      { 
       On = !On; 

      } 



     } 
     if ((GetAsyncKeyState(BindB)&1)) 
     { 
      On = !On; 
     } 
     if (On) 
     { 
      DrawGUIBox(x, y, w, h, r, g, b, a, onr,ong,onb, a); 
     } 

    } 
    bool Extract() 
    { 
     return On; 
    } 
    void Off() 
    { 
     On = false; 
    } 
private: 
    float x; 
    float y; 
    float w; 
    float h; 
    int r; 
    int g; 
    int b; 
    int a; 
    int rr; 
    int gg; 
    int bb; 
    int aa; 
    int onr; 
    int ong; 
    int onb; 
    int BindB; 
    bool On = false; 
    bool IsUP = true; 
}; 

Draw.h

#pragma once 
    #ifndef HDRAWFUNC_H 
    #define HDRAWFUNC_H 

    #include "DirectX.h" 

    #pragma warning(disable : 4244) //remove the incoming warns 
    #pragma warning(disable : 4996) //remove the incoming warns 

    #include <d3dx9.h> 
    #include <d3d9.h> 
    #define D3DFVF_TL (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1) 
    #pragma comment(lib, "d3d9.lib") 
    #pragma comment(lib, "d3dx9.lib") 
    static struct D3DTLVERTEX; 
    void GradientFunc(int x, int y, int w, int h, int r, int g, int b, int a); 
    void DrawCenterLine(float x, float y, int r, int g, int b, int a); 
    void DrawLine(float x, float y, float xx, float yy, int r, int g, int b, int a); 
    void DrawCursorLine(float x, float y, float xx, float yy, int r, int g, int b, int a); 
    void FillRGB(float x, float y, float w, float h, int r, int g, int b, int a); 
    void DrawBox(float x, float y, float width, float height, float px, int r, int g, int b, int a); 
    void DrawGUIBox(float x, float y, float w, float h, int r, int g, int b, int a, int rr, int gg, int bb, int aa); 
    void DrawHealthBar(float x, float y, float w, float h, int r, int g, int b); 
    void DrawHealthBarBack(float x, float y, float w, float h); 
    void DrawGroupBox(float x, float y, float w, float h, int r, int g, int b, int a, int rr, int gg, int bb, int aa, char* title); 
    int DrawString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont); 
    int DrawShadowString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont); 
    void DrawCircle(int x, int y, float radius, int Sides, D3DCOLOR color); 
    D3DTLVERTEX CreateD3DTLVERTEX(float X, float Y, float Z, float RHW, D3DCOLOR color, float U, float V); 
    void DrawFilledCircle(int xPos, int yPos, int Radius, D3DCOLOR color); 
    void FillARGBTriangle(int x1, int y1, int x2, int y2, int x3, int y3, D3DCOLOR color, IDirect3DDevice9 *pDevice); 
    #endif 

而且整個項目,如果你需要它。 https://yadi.sk/d/uOPt8pdC3Jb78o

+0

'#pragma once' +'#ifndef HDRAWFUNC_H' /'#define HDRAWFUNC_H' /'#endif'是多餘的。 – Borgleader

+0

我無法在hslider.h中找到Try2文本 – 2017-06-05 11:20:54

+0

您的意思是字體?Try2是項目的名稱.Font在DirectX.cpp中。 – bJing

回答

0

我找到了答案我自己。 問題在於圓形包含。 它發生是因爲我在頭文件中定義了我的類而不是.cpp文件。 這樣做並正確地移動標題我在幾分鐘內解決了它。

道德:永遠不要破壞C++規則。

0

該問題不在您的源代碼中。問題是您的Visual Studio解決方案文件(在您發佈的鏈接中)已損壞。在解決方案文件中有對稱爲Try2的項目的引用,但該解決方案中不存在此項目。

要解決此問題,請執行以下操作。

打開Help.sln文件,記事本+ +,你會看到有一行

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Try2", "Try2\Try2.vcxproj", "{BC659ABD-F853-4678-83AF-3D29339A7FC0}" 

這意味着,就是要一個子項目稱爲Try2,但它不存在。在你的檔案中,子項目實際上被稱爲「幫助」。因此,將該行更改爲:

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Help", "Help\Help.vcxproj", "{BC659ABD-F853-4678-83AF-3D29339A7FC0}" 

然後,通過解決方案中的x64文件夾並刪除任何引用Try2的殘留文件。

或者,創建一個新的空白解決方案,並將.cpp和.h源文件(僅)一次一個地複製到新解決方案中。

(還有在Offsets.h文件丟失一個單獨的問題,但我不能與幫助。)

相關問題