I am looking for a way of calling member function without creating instance of class, and I don't mean static function.
Here's the situation:
//Texture.cpp
#include "Window.hpp"//Window included
void Texture::Init(const char* path, const Window&)
{
loadTexture(path, Window.getRenderer();
}
void Texture::loadTexture(const char* path, SDL_Renderer* renderer)
{
//code...
}
Window has a member function SDL_Renderer* getRenderer(). However, I can't use it in this situation, because there is no instance of Window created.
I came across this question, and if I had to find a way by myself, I would do the same thing as the guy did: creating static function. However, this looks like going around a problem for me. The answer with using std::function and std::bind looked good to me, but I can't figure out how to use it. Could anyone help me please?
I have:
- function loadTexture, taking const char* and SDL_Renderer* as arguments, and returning void
- function Init, taking const char* and const Window& as arguments, and returning void
- class Window, which has function getRenderer, taking no arguments and returning SDL_Renderer*
Could anybody help me please, with explanation, so I could do the same thing by myself next time I encounter this problem?
Thanks in advance.