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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:34:47+00:00 2026-05-26T23:34:47+00:00

Being pretty new to C++, I don’t quite understand some instructions I encounter such

  • 0

Being pretty new to C++, I don’t quite understand some instructions I encounter such as:

#ifndef BOT_H_
#define BOT_H_

#include "State.h"

/*
    This struct represents your bot in the game of Ants
*/
struct Bot
{
    State state;

    Bot();

    void playGame();    //plays a single game of Ants

    void makeMoves();   //makes moves for a single turn
    void endTurn();     //indicates to the engine that it has made its moves
};

#endif //BOT_H_

What I don’t understand is the “#ifndef BOT_H_” and the “#define — #endif”

From what I gather, it defines a constant BOT_H_ if it’s not already defined when the precompiler looks at it. I don’t actually get how the struct inside it is a constant and how it is going to let me access the functions inside it.

I also don’t see why we’re doing it this way? I used C++ a while back and I wasn’t using .h files, so it might be something easy I’m missing.

  • 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-26T23:34:48+00:00Added an answer on May 26, 2026 at 11:34 pm

    It does not define a constant whose value is the struct. It defines a constant with an empty value.

    It’s there so that the content of the header is not included twice. Basically it says something like:

    if (!bot_h_included)
    {
        bot_h_included = true;
    
        // code from the header
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being new to c#, I don't understand how variables are passed between objects. My
I'm quite new to node.js, and pretty new to Javascript (I don't count simple
Being quite new to rails and currently building a project, i'm begining to be
I'm pretty new to eclipse and Android and I'm trying to add some files
I'm pretty new to rails, building my first 'real' app and struggling to understand
Being pretty unfamiliar with design patterns and architecture, I'm having trouble explaining to others
my question is pretty simple: can PHP and Java communicate, while PHP being the
Being new to SQLAlchemy, I was wondering at what time would Session() should be
Being new to OpenCL i would like to know if the following scenario is
Being fairly new to programming, I am having trouble understanding exactly what Homebrew does...

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.