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

Author Topic: Is this correct?  (Read 963 times)

0 Members and 1 Guest are viewing this topic.

ILostMyAccount

  • Newbie
  • *
  • Posts: 22
    • View Profile
Is this correct?
« on: February 06, 2015, 01:20:05 pm »
As the title says, is this correct?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Is this correct?
« Reply #1 on: February 06, 2015, 01:36:20 pm »
This is the most ambiguous, unproductive and ... silly.. question. Can you be more specific about what you are asking is "correct"?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Is this correct?
« Reply #2 on: February 06, 2015, 01:44:12 pm »
As Gambit said, be specific when you ask a question. Please read this carefully: http://en.sfml-dev.org/forums/index.php?topic=5559.0

And please provide real code that we can copy, not a screen capture.

To answer the question: no, this code is not correct. What your constructor does is to create its own copy the texture, but I assume that you just want to use the original one.

const sf::Texture& m_texture;

Player::Player(const sf::Texture& texture) : m_texture(texture)
{
    ...
}

Or

const sf::Texture* m_texture;

Player::Player(const sf::Texture& texture)
{
    m_texture = &texture;
}

This comment and solution are based on assumption about what you want to do, so no guarantee that it matches what you were asking.
Laurent Gomila - SFML developer

 

anything