Engineという名前のクラスがあります。 TextureManagerクラスのオブジェクトは、クラスEngineの内部およびWindowクラスのオブジェクトです。2つのクラスのスコープに関するエラー
私の問題は、TextureManagerの内部の関数は、クラスウィンドウ内のパブリック関数または変数にアクセスできないということです。
これはC++の意図した機能ですか、私はこれらのオブジェクトの一方または両方を間違って宣言/定義していると思いますか?
ご覧のとおり、エンジン内部にはTextureManagerとウィンドウがあります。ここで
class Engine
{
public:
Engine();
~Engine();
Window gameWindow;
TextureManager textures;
SDL_Event event;
int test;
};
はクラスウィンドウのヘッダー
class Window
{
public:
//Constructors
Window();
~Window();
//Getter Functions
SDL_Surface * get_screen();
//Other Functions
void toggle_fullscreen();
void render();
void initialize(int screenwidth, int screenheight);
bool handle_events(SDL_Event event);
bool check_error();
private:
bool windowed;
bool windowFailure;
int screenWidth;
int screenHeight;
SDL_Surface * screen;
};
ここでは、クラスTextureManager
class TextureManager
{
public:
TextureManager();
~TextureManager();
int new_texture(std::string filename);
int new_section(int indexOfTexture, int x, int y, int width, int height);
void render_texture(int textureID, int x, int y);
void render_section(int textureSectionID, int x, int y);
private:
std::vector<Texture> textureIDs;
std::vector<TextureSection> textureSectionIDs;
};
のヘッダファイルであり、これは、私はとのトラブルを抱えている機能です。関数呼び出しSDL_BlitSurface()
void TextureManager::render_texture(int textureID, int x, int y)
{
SDL_Rect coordinates;
coordinates.x = x;
coordinates.y = y;
SDL_BlitSurface(textureIDs[textureID].get_texture(), NULL, gameWindow.get_screen(), &coordinates);
}
あなたが必要があるかもしれません:あなたはTextureManagerがgameWindowと対話できるようにするには、次のアプローチを考慮することができます**非常に短い**ビットのコードを投稿する。 – drdwilcox
はい、私はあなたのコードの記述が単なる例を投稿するよりも簡単であると仮定して間違ってしまったと思います! –
十分な公正な、いくつかのソースを今すぐ投稿 – Alidaco