Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Access violation on initializing sf::Text and, may I ask a favor?  (Read 1400 times)

0 Members and 1 Guest are viewing this topic.

duduphysicist

  • Newbie
  • *
  • Posts: 2
    • View Profile
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!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Access violation on initializing sf::Text and, may I ask a favor?
« Reply #1 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)
Back to C++ gamedev with SFML in May 2023

duduphysicist

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Access violation on initializing sf::Text and, may I ask a favor?
« Reply #2 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!

 

anything