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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:20:56+00:00 2026-06-13T01:20:56+00:00

What happens if I include iostream or any other header file twice in my

  • 0

What happens if I include iostream or any other header file twice in my file?
I know the compiler does not throw error.

Will the code gets added twice or what happens internally?

What actually happens when we include a header file ?

  • 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-13T01:20:57+00:00Added an answer on June 13, 2026 at 1:20 am

    Include guard prevents the content of the file from being actually seen twice by the compiler.

    Include guard is basically a set of preprocessor’s conditional directives at the beginning and end of a header file:

    #ifndef SOME_STRING_H
    #define SOME_STRING_H
    
    //...
    
    #endif 
    

    Now if you include the file twice then first time round macro SOME_STRING_H is not defined and hence the contents of the file is processed and seen by the compiler. However, since the first thing after #ifdef is #define, SOME_STRING_H is defined and the next time round the header file’s content is not seen by the compiler.

    To avoid collisions the name of the macro used in the include guard is made dependent on the name of the header file.

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

Sidebar

Related Questions

Does the standard define what happens with this code? #include <iostream> template <typename Func>
What happens when a thread is put to sleep by other thread, possible by
What happens in the following code? Does the synchronization work? This is an interview
What happens when an application pool is recycled in IIS 7? Does IIS abruptly
What happens if I call startUpdatingLocation while startMonitoringSignificantLocationChanges is running? Does significantLocationChange monitoring get
Consider the following code: #include <iostream> struct test { void public_test() { [this]() {
Here's the code: // WAP to implement student result preparation. #include stdafx.h #include iostream
Basically it is the following code, which cannot pass compiler (g++) #include <boost/program_options.hpp> #include
#include <iostream> using namespace std; class CTest { int x; public: CTest() { x
#include <iostream> #include <string.h> using namespace std; void newBuffer(char* outBuffer, size_t sz) { outBuffer

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.