SFML community forums

Help => General => Topic started by: duduphysicist on November 03, 2012, 05:36:10 pm

Title: Access violation on initializing sf::Text and, may I ask a favor?
Post by: duduphysicist on November 03, 2012, 05:36:10 pm
Hello!
I'm a begginer, in fact that's my first real project; it's a birthday card to one friend (it's TODAY in fact...) and I am having some problems with access violations. I'm using Visual Studio 2012 under windows 7, I will try to upload it somewhere, could someone give a look to help me? The error ocurrs on the constructor of my message class, on the Text constructor:

Message::Message(string text, Font font)
     : message(text,font) // 'message' is sf::Text; the debugger brought me there
{
      // Other initializations
}

Thanks in advance!
Title: Re: Access violation on initializing sf::Text and, may I ask a favor?
Post by: FRex on November 03, 2012, 05:39:00 pm
Passing by value is not good idea for fonts(and strings here too), write "const TYPE& NAME" instead of "TYPE NAME".
Message::Message(const string& text,const Font& font)
Title: Re: Access violation on initializing sf::Text and, may I ask a favor?
Post by: duduphysicist on November 03, 2012, 06:32:25 pm
Sorry, I typed it wrong, I'm passing the font by reference. I got the error, was forgetting to initialize the font :p  Thanks!