I'm 13 and still quite new to OpenGL and graphical libraries in general. Currently I'm working on a OpenGL project and I have multiple errors stating that a base class is undefined, for example, 'GameObject' base class undefined
. I have tried a multitude of things such as making sure all the header files only used pragma once
instead of a mix of pragma
and ifndef
. I have also made sure that all my includes are in order and even forward declared important classes.
Here's a small snippet of a class where it has inherited GameObject and included the GameObject header file but still states that the header class is undefined:
#pragma once
class Game;
#include "game.h"
#include <glm/glm.hpp>
#include <vector>
#include "GameObject.h"
#include "shaderclass.h"
#include "Camera.h"
class Paddle : public GameObject {
public:
enum CONTROLTYPE { WASD, ARROW };
CONTROLTYPE type;
Paddle(glm::vec3 position, glm::vec3 scale, CONTROLTYPE type, glm::vec3 velocity);
void update(Game* g, GLFWwindow* gameWindow);
};
(I did not forward declare GameObject but if I did it would still output the same error)
GameObject header file:
#pragma once
class Game;
#include "game.h"
#include "shaderclass.h"
#include"ROML.h"
#include<glm/glm.hpp>
#include "Mesh.h"
class GameObject {
public:
//etc...
Full build error:
Error C2504 'GameObject': base class undefined OpenPong
Unfortunately, due to the size of the project I cant provide a minimal reproducible example here but here's the GitHub repository if you would like to look further into the code: https://github.com/ghostly-developer/OpenPong/tree/%232-classes
I also don't have any intellisense errors that could've caused this.
Thanks!