Napotkałem ten błąd wiele razy wcześniej i ostatecznie znalazłem rozwiązania, ale ten ma mnie zakłopotany. Mam klasę "Mob" odziedziczoną po klasie "Player". To Mob.h:error C2504: base class undefined
#pragma once
#include "PlayState.h"
#include "OmiGame/OmiGame.h"
#include "resources.h"
class PlayState;
class Mob
{
private:
int frames;
int width;
int height;
int time;
sf::Texture textureL;
sf::Texture textureR;
Animation animationL;
Animation animationR;
AnimatedSprite sprite;
bool moveLeft;
bool moveRight;
bool facingRight;
public:
void createMob(std::string l, std::string r, int frames, int width, int height, int time, int x, int y);
void updateMob(omi::Game *game, PlayState *state);
void drawMob(sf::RenderTarget &target);
void setLeft(bool b) { moveLeft = b; }
void setRight(bool b) { moveRight = b; }
bool isLeft() { return moveLeft; }
bool isRight() { return moveRight; }
sf::Vector2f getPosition() { return sprite.getPosition(); }
};
to Player.h, jak na razie jest bardzo prosta:
#pragma once
#include "OmiGame/OmiGame.h"
#include "PlayState.h"
#include "Mob.h"
#include "resources.h"
class PlayState;
class Mob;
const int playerFrames = 8;
const int playerWidth = 16;
const int playerHeight = 48;
const int playerTime = 50;
const int playerX = 200;
const int playerY = 200;
class Player : public Mob
{ //the error occurs at this line//
public:
Player();
void update(omi::Game *game, PlayState *state);
void draw(sf::RenderTarget &target);
};
I, jak można się domyślić, jest to błąd:
error C2504: 'Mob' : base class undefined player.h
Mam zadeklarowany mob, mam nadzieję, że naprawiłem wszelkie zależności kołowe. Czy ktoś może mi pomóc?
Czy pliki znajdują się w tym samym katalogu? – ChiefTwoPencils
Wiesz, to jakoś pokonuje enkapsulację, jeśli zapewnisz dostęp do wszystkich swoich prywatnych członków ... – Deduplicator
@Deduplicator Nie ma. Tylko czterech członków prywatnych ma akcesorów, ponieważ moby muszą reagować inaczej na ich podstawie, ale muszą dzielić tych członków, aby ponownie wykorzystany kod mógł również uzyskać do nich dostęp. –