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

while reading about declare construct from php manual i tried the following example using
When reading about SQL I've come across the term 'slot'. For example, in a
After reading about it for so long, I now have chance to get my
I recall reading about a broadcast receiver interface from the sync adapter or some
Reading about TFS' MSF for Agile Software Development v5.0 template ( for example here
Reading about the G.729 codec , I found this interesting tidbit about Comfort Noise
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome
Reading about Django, I saw this: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin - the fancy simple to use admin
When reading about SQL Injection and XSS i was wondering if you guys have

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.