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

Author Topic: Returning struct from function is not working  (Read 1032 times)

0 Members and 1 Guest are viewing this topic.

Putarda

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Returning struct from function is not working
« on: September 08, 2016, 01:04:06 am »
Returning struct from function is not working, and i don't know why. Can someone help me?
        struct Position {

                float x, y;

                Position(float position_x, float position_y) {

                        x = position_x;

                        y = position_y;

                }

        };
        Position Object::getPosition() {

                Position position(sprite.getPosition().x, sprite.getPosition().y);

                return position;
        }
        void updateGame() {

                int ball_position_main_x = 50, ball_position_main_y = 50;

                while (game_run) {

                        std::cout << Object::getObject("test")->getPosition().x;

                        Object::getObject("test")->moveRight(1);

                        sf::sleep(sf::milliseconds(10));

                }

        }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Returning struct from function is not working
« Reply #1 on: September 08, 2016, 07:44:36 am »
Remember that this is the SFML forum. There are a lot of dedicated places around the internet that are more suitable for pure C++ questions.

And if you want some help, please describe your problem better than "it is not working".
Laurent Gomila - SFML developer

 

anything