0

当我自己使用静态成员时,所以:

window::gfx;

它编译得很好,但是每当我使用该成员函数时,所以:

window::gfx.set_background(BLACK);

我收到以下错误:

undefined reference to `window::gfx'

我已经编写了涉及此错误的文件,但是我的所有代码都保留在:https ://github.com/averagedolphin/pong

主.cpp:

#include <iostream>
#include "raylib.h"
#include "window/window.h"


int main()
{
    window window;

    while (!WindowShouldClose())
    {
        // Graphics gui phase
        BeginDrawing();
        window::gfx.set_background(BLACK);
        EndDrawing();
    }
}

窗口.h:

#pragma once

#include "../macros.h"

#include "graphics/graphics.h"
#include "gui/gui.h"
#include "control/control.h"


class window
{
private:

public:


    static graphics gfx;
    static gui gfxui;
    window();

};

窗口.cpp:

#include "window.h"

#include "raylib.h"
#include "../macros.h"
#include "control/control.h"
#include "graphics/graphics.h"
#include "gui/gui.h"

window::window()
{
    InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE);

    // Initialize subclasses

}

图形.h:

#pragma once

#include "raylib.h"

class graphics
{
public:
    void set_background(Color clr);
};

图形.cpp:

#include "graphics.h"

#include "raylib.h"

void graphics::set_background(Color clr)
{
    ClearBackground(clr);
}

谢谢,

4

0 回答 0