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 761099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:47:52+00:00 2026-05-14T15:47:52+00:00

I am currently working on a project that deals with a vector of objects

  • 0

I am currently working on a project that deals with a vector of objects of a People class. The program compiles and runs just fine, but when I use the debugger it dies when trying to do anything with the PersonWrangler object. I currently have 3 different classes, one for the person, a personwrangler which handles all of the people collectively, and a game class that handles the game input and output.

Edit: My basic question is to understand why it is dying when it calls outputPeople. Also I would like to understand why my program works exactly as it should unless I use the debugger. The outputPeople function works the way I intended that way.

Edit 2: The callstack has 3 bad calls which are:

  1. std::vector >::begin(this=0xbaadf00d)
  2. std::vector >::size(this=0xbaadf00d)
  3. PersonWrangler::outputPeople(this=0xbaadf00d)

Relevant code:

class Game
{
public:
    Game();
    void gameLoop();
    void menu();
    void setStatus(bool inputStatus);
    bool getStatus();
    PersonWrangler* hal;
private:
    bool status;
};

which calls outputPeople where it promptly dies from a baadf00d error.

void Game::menu()
{
    hal->outputPeople();
}

where hal is an object of PersonWrangler type

class PersonWrangler
{
public:
    PersonWrangler(int inputStartingNum);
    void outputPeople();  
    vector<Person*> peopleVector;
    vector<Person*>::iterator personIterator;  
    int totalPeople;
};

and the outputPeople function is defined as

void PersonWrangler::outputPeople()
{
    int totalConnections = 0;
    cout << " Total People:" << peopleVector.size() << endl;
    for (unsigned int i = 0;i < peopleVector.size();i++)
    {
        sort(peopleVector[i]->connectionsVector.begin(),peopleVector[i]->connectionsVector.end());
        peopleVector[i]->connectionsVector.erase( unique (peopleVector[i]->connectionsVector.begin(),peopleVector[i]->connectionsVector.end()),peopleVector[i]->connectionsVector.end());
        peopleVector[i]->outputPerson();
        totalConnections+=peopleVector[i]->connectionsVector.size();
    }
    cout << "Total connections:" << totalConnections/2 << endl;
}

Where hal is initialized

Game::Game()
{
    PersonWrangler* hal = new PersonWrangler(inputStartingNum);
}
  • 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-05-14T15:47:53+00:00Added an answer on May 14, 2026 at 3:47 pm

    0xBAADFOOD is a magic number to alert you to the fact that you’re dealing with uninitialized memory. From the stack trace, we see that this in PersonWrangler::outputPeople is invalid. Thus hal doesn’t point to a valid PersonWrangler (that is, assuming frame 4 is a call to Game::menu). To resolve this sort of thing yourself, step through the code, starting at Game::Game(), examining Game::hal as you go, to see what might be going wrong.

    In Game::Game, hal is a local variable that shadows Game::hal. When Game::Game exits, this hal goes out of scope and leaks memory, while Game::hal remains uninitialized. What you want is:

    Game::Game()
    {
        hal = new PersonWrangler(inputStartingNum);
    }
    

    Debuggers fill uninitialized memory with magic numbers to make it easier to spot errors. In a production build, memory isn’t filled with anything in particular; the content of uninitialized memory is undefined, and might hold valid values. This is why a production build might not fail when a debug build will.

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

Sidebar

Related Questions

I have a project that I'm currently working on but it currently only supports
I'm working on a project that currently has zero users but we would like
I am currently working on a project that is moving from .NET 2.0 to
I am currently working on a project that will store specific financial information about
I'm currently working on a project that hooks into various system calls and writes
I'm currently working on a project that contains many different Eclipse projects referencing each
I'm currently working on creating a new C# project that needs to interact with
I'm currently working on a Java project that is emitting the following warning when
I'm currently working on a project for medical image processing, that needs a huge
I am currently working on a project that needs to be able to set

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.