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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:55:15+00:00 2026-05-15T07:55:15+00:00

I was reading about SIOF from a book and it gave an example :

  • 0

I was reading about SIOF from a book and it gave an example :

//file1.cpp
extern int y;
int x=y+1;

//file2.cpp
extern int x;
int y=x+1;  

Now My question is :
In above code, will following things happen ?

  1. while compiling file1.cpp, compiler leaves y as it is i.e doesn’t allocate storage for it.
  2. compiler allocates storage for x, but doesn’t initialize it.
  3. While compiling file2.cpp, compiler leaves x as it is i.e doesn’t allocate storage for it.
  4. compiler allocates storage for y, but doesn’t initialize it.
  5. While linking file1.o and file2.o, now let file2.o is initialized first, so now:
    Does x gets initial value of 0? or doesn’t get initialized?
  • 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-15T07:55:16+00:00Added an answer on May 15, 2026 at 7:55 am

    The initialization steps are given in 3.6.2 “Initialization of non-local objects” of the C++ standard:

    Step 1: x and y are zero-initialized before any other initialization takes place.

    Step 2: x or y is dynamically initialized – which one is unspecified by the standard. That variable will get the value 1 since the other variable will have been zero-initialized.

    Step 3: the other variable will be dynamically initialized, getting the value 2.

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

Sidebar

Related Questions

I've been reading about UpdateFrom, used to update a business object from the request.
I was reading about data driven testing using mbunit from this article. http://blog.benhall.me.uk/2007/04/mbunit-datafixture-data-driven-unit.html I
Reading about the G.729 codec , I found this interesting tidbit about Comfort Noise
When reading about SQL Injection and XSS i was wondering if you guys have
I am reading about COFF file formats, which is commonly used to create an
I was reading about output buffering in JavaScript here , and was trying to
I keep reading about C99 and C++11 and all these totally sweet things that
I've been reading about the new developer-only RC0 for Silverlight, and the fact that
I keep reading about people who are test infected, meaning that they don't just
I keep reading about how great this new Canvas element for HTML5 is and

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.