Hi there.
First of all I want to admit that I am just a beginner but I think this doesn't excuse me : P
I wanted to make a class that has an sf::String object as a member. As this object created without the font argument crashes the program after closing I came to those two solutions:
1. Initialize the object in an initialization list like that:
CText(sf::Font& f) : m_string("Sometext", f, 40.f) {}
but with this solution I have to create additional useless instance of sf::Font before I create a CText object like that:
sf::Font _fnt;
_fnt.LoadFromFile("arial.ttf");
CText Foobar(_fnt);
which I wanted to avoid.
2. Create a pointer to the sf::String and create object of it in a constructor:
CText()
{
sf::Font _font;
_font.LoadFromFile("arial.ttf");
this->m_string = new sf::String("Text", _font, 40.f);
}
this one would be cool, but when I try to draw the object:
void Draw(sf::RenderTarget &target)
{
target.Draw(*m_string);
}
I get a crash. I assume that I am making something stupid but my lack of knowledge disallows me to see what am I doing wrong.