Ada*_*ith 2 c++ precompiled-headers c-preprocessor
作为C++的新手,我不太了解我遇到的一些指令,例如:
#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_
Run Code Online (Sandbox Code Playgroud)
我不明白的是"#ifndef BOT_H_"和"#define - #endif"
从我收集的内容中,它定义了一个常量BOT_H_,如果在预编译器查看它时尚未定义它.我实际上并没有得到它内部的结构是一个常量,以及如何让我访问其中的函数.
我也不明白为什么我们这样做呢?我曾经使用过C++而我没有使用.h文件,所以它可能很容易让我失踪.
归档时间: |
|
查看次数: |
266 次 |
最近记录: |