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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:34:50+00:00 2026-06-18T11:34:50+00:00

When will a fundamental C++ type, such as int or float , have an

  • 0

When will a fundamental C++ type, such as int or float, have an unknown initial value?

How does the type of memory allocation factor in, if at all? What about the declaration? What if it’s a member of a class/struct/union? Is C++11 different from C++03 or C++98?

I have my suspicions, but no idea if my knowledge is complete (or correct, for that matter)

  • 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-18T11:34:51+00:00Added an answer on June 18, 2026 at 11:34 am

    Any POD data (including all fundamental types) will have an unknown value when both:

    • it doesn’t have static memory allocation (it’s instead created on the stack or with new)
    • it isn’t initialized, including empty initialization and/or constructor initialization lists

    Global/static variables, of all types, are set to zero as part of the startup process before main is called. Constructors are called for types that have constructors before main 1.

    Anything not initialized in the constructor is also unknown.

    Edit: to clarify, std::string is a good example of “constructor not initializing everything” – if you have a local std::string str;, then str will have a defined “empty string” content, but the content of the actual buffer, or indeed what the buffer points at may not be set to anything meaningful at all – as the implementation may determine based on the length [or some other way] whether there is a buffer available or not once we start using the string to store stuff].

    Edit2: As the comment explains, you can also have “hybrid” cases, where parts of a structure is being initialized, e.g. a struct that contains some elements of “plain data” and some elements that have constructors. The ones that have constructors will have their constructor called. The plain data will not be initialized.

    1 It may well be that the code running constructors is part of, or called from inside the “main” function – but if that is the case, it will be “before any of your code in main is started”.

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

Sidebar

Related Questions

Will my windows-7, command prompt allow me to filter memory logcat messages for my
Does anyone know whether a DOM Node of type Text is guaranteed not be
I have a struct: struct OutputStore { int myINT; string mySTRING; } If I
All of the ExceptionHandlerFactory examples I have come across so far redirect a user
I have requirement to plot Fundamental Score and Technical Score for each ticker across
I have trouble understanding a fundamental concept in Java 2D. To give a specific
From: http://doc.qt.nokia.com/4.7/signalsandslots.html Callbacks have two fundamental flaws: Firstly, they are not type-safe. We can
I have the need to download all files in an ftp directory. I don't
I'm writing a Java wrapper for an API and I have a fundamental question
I have a fundamental design question in modelling the relationships between the entities for

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.