A
A
ascherbinin822020-11-11 16:17:56
OOP
ascherbinin82, 2020-11-11 16:17:56

Member with constructor not allowed in anonymous aggregate?

Weird error:
member 'IWindowSystem ::' with copy assignment operator not allowed in anonymous aggregate
class GLFW : IWindowSystem
-------------^-------------- ------
WindowSystem.cpp:

#include <WindowSystem.hpp>
#include <stddef.h>
#define GLFW
#ifdef GLFW
#include <GLFW/glfw3.h>
class GLFWWin : public IWindow
{
private:
    void (*CallBack)(IWindow *, int, int);
    GLFWwindow *window;
    

public:
    void static WindowResizeCallBack(GLFWwindow* window, int width, int height) {

    }
    GLFWWin(GLFWwindow *window)
    {
        this->window = window;
    }
    virtual void *getLowLevelInfo()
    {
        return window;
    }
    virtual void setWindowResizeCallBack(void (*CallBack)(IWindow *, int, int))
    {
        this->CallBack = CallBack;
        glfwSetFramebufferSizeCallback(window, GLFWWin::WindowResizeCallBack);
    }
};

class GLFW : public IWindowSystem
{
public:
    virtual void initWindowSystem()
    {
        glfwInit();
    }
    virtual IWindow *createWindow(const char *title, int width, int height)
    {
        return (IWindow *)new GLFWWin(glfwCreateWindow(width, height, title, NULL, NULL));
    }
    virtual IWindow *createFullScreenWindow(const char *title)
    {
        GLFWmonitor *monitor = glfwGetPrimaryMonitor();
        const GLFWvidmode *mode = glfwGetVideoMode(monitor);
        return new GLFWWin(glfwCreateWindow(mode->width, mode->height, title, monitor, NULL));
    }
};
#endif

WindowSystem.hpp:
class IWindow
{
public:
    virtual void *getLowLevelInfo() = 0;
    virtual void setWindowResizeCallBack(void (*CallBack)(IWindow *, int, int)) = 0;
};
class IWindowSystem
{
public:
    virtual void initWindowSystem() = 0;
    virtual IWindow *createWindow(char **title, int width, int height) = 0;
    virtual IWindow *createFullScreenWindow(char **title) = 0;
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xorknown, 2020-11-11
@xorknown

one)

#define GLFW
#ifdef GLFW

class GLFW : public IWindowSystem 
-> class : public IWindowSystem {}

You define an empty macro named GLFW, then create a class with the same name. What are you trying to achieve?
2) IWindowSystem and GLFW method signatures are disabled
virtual IWindow *createFullScreenWindow(char **title) = 0;
-> virtual IWindow *createFullScreenWindow(const char *title) {}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question