When I use a static member by itself, so:
window::gfx;
It compiles fine, but whenever I use that members function, so:
window::gfx.set_background(BLACK);
I get the following error:
undefined reference to `window::gfx'
I have wrote the files that involve this error, however all of my code is left at: https://github.com/averagedolphin/pong
main.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();
}
}
window.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();
};
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
}
graphics.h:
#pragma once
#include "raylib.h"
class graphics
{
public:
void set_background(Color clr);
};
graphics.cpp:
#include "graphics.h"
#include "raylib.h"
void graphics::set_background(Color clr)
{
ClearBackground(clr);
}
Thanks,