Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:02:59+00:00 2026-06-15T07:02:59+00:00

I have these two pieces of code that are messing up without throwing any

  • 0

I have these two pieces of code that are messing up without throwing any errors:

The first piece is from a custom class which I am trying to push into an array.

class idRect {
    public:
        sf::FloatRect rect;
        int id;

        idRect(int _id, sf::FloatRect _rect) : id(_id), rect(_rect) {}
};

The second piece is where the function gets called.

if((deltaX + deltaY) < 500) { //Taxi distance calculation
    cout << endl << "Passed check" << endl;
    gloAreas.push_back(idRect(id, entity.getGlobalBounds()));
}

gloAreas is a globally defined vector which contains idRect objects.

As said earlier I have observed from the console that “Passed check” outputs and that the size of my vector doesn’t increase EDIT: globally.

Edit: The error also seems rather random and only happens for 1 in 6 instances of the objects calling the push_back functions.

I’m using SFML for the sf::FloatRect which is basically just a vector of 4 floats. getGlobalBounds() is another function from SFML that returns the bounding rectangle of a sprite in sf::FloatRect format.

Any ideas of what is going wrong?

Sincerely,
BarrensZeppelin

EDIT 2:
The error seems to have erupted due to a mix between my own incompetence and std::multiset’s sorting, maybe I’ll come back for that in another thread ^^ (With a sscce ofc)
Thank you guys for you time and help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:03:00+00:00Added an answer on June 15, 2026 at 7:03 am

    If gloAreas is defined as static, it won’t be a true global. It will have global scope, but a copy of it will be created for each translation unit.

    For a global, you need to declare it with extern and define it in a single implementation file.

    Disclaimer: answer is just a guess, my crystal ball might be off today…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two pieces of code that each return a relation inside the
I have these two pieces of code that could possibly be run at the
I have a question about the difference between these two pieces of code: char
I have two pieces of code that I'm using to learn about multiprocessing in
I currently have a Python 2.6 piece of code that runs two loops simultaneously.
I have these two methods on a class that differ only in one method
I have these two data structures that I continually find myself choosing between when
I currently have a piece of code that I am working on using function
Why these two pieces of codes, running on same conditions, does not have difference
I have two pieces of code.They work properly when it is used alone in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.