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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:20:04+00:00 2026-05-26T19:20:04+00:00

My current implementation of how to output my binary tree is getting me an

  • 0

My current implementation of how to output my binary tree is getting me an error in g++, along the lines of

Conditional jump or move depends on uninitialised value(s)

My current implementation is:

void Foo::output(ostream &s, const Node *p)
{
    if( p )
    {
        output( s , p -> left );

        s << p -> info; 

        output( s , p -> right );
    }
}

The Node is a basic struct, with a left and right pointer, and an integer info variable.

the ostream is just cout

The error message is very straight forward, it doesn’t like that I let it “run off”.

My question is twofold:

  1. Why is this improper? Nothing is being changed, I don’t know what it can hurt.
  2. What is the proper way to do this?

Thanks

  • 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-26T19:20:05+00:00Added an answer on May 26, 2026 at 7:20 pm

    Basically it means that some Node objects do not have left and right initialized to null.

    Typically it is a good idea to define your node something like this

    class Node
    {
        int info;
        Node* left;
        Node* right;
    
    public:
    
        Node( int infoin , Node* leftin = NULL , Node* rightin = NULL )
         : info(infoin) , left(leftin) , right(rightin) {}
    
    }
    

    This way if left and right nodes are not known at construction time , they are set to null.

    And if they are indeed known at construction of Node you don’t pay the penalty of setting right and left to null and then to something else

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

Sidebar

Related Questions

I've tried with Postsharp, but their current implementation targets 2.0, and it's getting painful
The current implementation of Remy Sharp's jQuery tag suggestion plugin only checks for matches
My current implementation of an Hash Table is using Linear Probing and now I
Paramiko's SFTPClient apparently does not have an exists method. This is my current implementation:
Implementing Equals() for reference types is harder than it seems. My current canonical implementation
A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy
I read that with .NET Framework 4 the current garbage collection implementation is replaced:
The current guidlelines for explicit member implementation recommend: Using explicit members to approximate private
What's the current status of Mono 's Platform Invoke implementation on Linux and on
There is a custom implementation of KSPA which needs to be re-written. The current

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.