#ifndef TREE_NODE
#include "TreeNode.h"
#endif
#ifndef SEARCH_TREE
#include "SearchTree.h"
#endif
what does this code mean?
#ifndef TREE_NODE
#include "TreeNode.h"
#endif
#ifndef SEARCH_TREE
#include "SearchTree.h"
#endif
what does this code mean?
-mayfda-
This means that if TREE_NODE is not defined already, then include TreeNode.h, which will most likely #define TREE_NODE. It's to prevent including a file twice.
__ &n bsp; ___ & nbsp; &nb sp;   ;
/\ \ __ &nbs p; /\_ \   ; & nbsp;
\_\ \/\_\ ____ _ __\//\ \ __ __&n bsp; __
/'_` \/\ \/\_ ,`\ / __`\\ \ \ /\ \/\ \ /'__`\
/\ \_\ \ \ \/_/ /_/\ \_\ \\_\ \_\ \ \_/ |/\ __/
\ \___,_\ \_\/\____\ \____//\____\\ \___/ \ \____\
\/__,_ /\/_/\/____/\/___/ \/____/ \/__/ \/____/
&n bsp; I have a BAD figlet& nbsp;addiction.
#ifndef stands for "If Not Defined"
C / C++ supports multiple declaration but single definition.
Hence if you have a class definition or something like that in a headerfile, if you include it more than once directly or indirectly, the compiler would generate an error.
#ifndef XYZ
#define XYZ
// your class definitions etc comes here
#endif
When the compiler reads it for the first time, XYZ is not defined, hence it would enter the conditional-preprocessor directive and within that we are defining XYZ. If it revisits this, any other time, XYZ is defined and hence would not enter the coditional-preprocessor directive, thus preventing multiple definition.
Last edited by shiv_tech_quest; 01-12-2003 at 10:35 PM.
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
To make your code more modular. Say you have two or more files (modules) that need to include iostream.h. Each file can say "If iostream has not been included yet, then include it now."