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

  • Home
  • SEARCH
  • 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 8829717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:53:54+00:00 2026-06-14T07:53:54+00:00

When I create header file in Microsoft Visual Studio, it’s just a blank file,

  • 0

When I create header file in Microsoft Visual Studio, it’s just a blank file, and I often add some prototype of function or class etc…

When I create header file from Netbean. It’s often has this structure. (Assume my header file is example):

#ifndef EXAMPLE_H
#define EXAMPLE_H
// put code here
#endif

Please tell me, meaning of those bunch of codes above. If I delete this, are there any problem ? I feel strange because VS doesn’t generate 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-06-14T07:53:55+00:00Added an answer on June 14, 2026 at 7:53 am

    These are called include guards, they prevent multiple definition errors when you include the same file multiple times. Even if you don’t, they don’t hurt anybody, so you might as well leave them in.

    How it works is, it checks if the macro EXAMPLE_H is defined. If it is, it leaves out the entire file. If it isn’t, it defines it, and keeps the file. That way, the next time this file appears the contents are left out.

    This often happens if you have two different headers that include the same header, such as:

    a.h

    #ifndef A_H
    #define A_H
    struct Foo {};
    #endif
    

    b.h

    #include "a.h"
    #ifndef B_H
    #define B_H
    struct Bar
    {
        Foo x;
    };
    #endif
    

    c.h

    #include "a.h"
    #ifndef C_H
    #define C_H
    struct Baz
    {
        Foo f;
    };
    #endif
    

    And then you create stuff.cpp with

    #include "b.h"
    #include "c.h"
    Bar y;
    Baz z;
    

    after preprocessing stuff.cpp will have

    struct Foo {};
    
    struct Bar
    {
        Foo x;
    };
    struct Baz
    {
        Foo f;
    };
    Bar y;
    Baz z;
    

    as opposed to (without include guards)

    struct Foo {};
    struct Bar
    {
        Foo x;
    };
    
    struct Foo {};
    struct Baz
    {
        Foo f;
    };
    Bar y
    

    which will give you an error about multiple definitions of Foo.

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

Sidebar

Related Questions

So, I create a header file that has the following: namespace A { template<int
I am trying to create a java header file. I compiled the project in
In Linux, to create a socket we include the sys/socket.h header file and use
I want to create a custom navigation bar to put in my header.phtml file.
I am trying to dynamically create an XML file using php like this: header
I created a header file called ofdm.h which includes all the function prototypes. Then
When I create shared libraries, I have a header file (but with no file
If a header file contains a function definition it can be inlined by the
I am trying to create header file for java native method in android application
I recently created a new header file that I want to include in the

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.