0

When attempting to refer to Albert.h class in my Game.cpp, I'm getting

repos\Pong\Game.h(23,9): error C3646: 'albert': unknown override specifier
repos\Pong\Game.h(23,15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Game.h

#pragma once

#include <iostream>
#include <ctime>

#include "Include.h"

#include "Ball.h"
#include "Player.h"
#include "Albert.h"

class Game
{

private: 

    sf::VideoMode videoMode;
    sf::RenderWindow* window;
    sf::Event event;

    Ball ball;
    Player player;
    Albert albert;

    //Game Logic
    bool endGame;

    //Private Functions
    void initVariables();
    void initWindow();


public:

    //Constructor / Destructor
    Game();
    virtual ~Game();

    //Accesssors
    bool const isRunning() const;


    //Function
    void PollEvents();
    void Update();
    void UpdateCollisions();

    void Render();
};

Albert.h

#pragma once

#include "Game.h"

class Albert
{
private:

    sf::RectangleShape shape;

    Ball ball;

    float moveSpeed;

    void initVariables();
    void initShape();

public: 

    Albert();
    virtual ~Albert();

    void Update();
    void Brain();
    void Render(sf::RenderTarget* target);

};

I've gotten this a couple of times and usually fix it by changing my includes around but with this, I'm unable to without breaking something else. And everything I've searched so far has talked about stop using namespaces and all of that while I'm not using any.

  • With strange errors like this a suspect is one of the other header files (or the command line) `#defining` a name or keyword used in the program. Note also `game.h` includes `Albert.h` which includes `game.h` etc ... – Richard Critten Jul 18 '21 at 09:25
  • 3
    You have a circular inclusion dependency that you need to break. Do `Albert.h` really need `Game.h`? Or does it need only a *small* part of it (like one or two `#include` directives; Tip: Only `#include` what you really need and nothing more)? – Some programmer dude Jul 18 '21 at 09:26

0 Answers0