SFML community forums

Help => General => Topic started by: Putarda on September 08, 2016, 01:04:06 am

Title: Returning struct from function is not working
Post by: Putarda 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));

                }

        }
Title: Re: Returning struct from function is not working
Post by: Laurent 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".