I currently have the following in my header file:
class Scene {
private:
const char* file;
public:
void sceneRender();
void setFile(const char* f) { file = f; }
void printFile() { cout << file; }
};
I want to define this function in another file apart from it but am having trouble with what to put inside of texture.loadFromFile() in order to make it run. It runs fine if I just keep this whole thing in the class definition in the header.
void sceneRender() {
sf::Event event;
sf::Texture texture;
texture.loadFromFile(file);
sf::Sprite sprite;
sprite.setTexture(texture);
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Black);
window.draw(sprite);
window.display();
}
Is there a way to do this. Also is there any advantage to defining all of ones functions outside the header file where the class is aside from aesthetics?
Thank you