What’s Next 755
21
Checking on the definitions of DemoVersion, NT_VERSION,_and
WINDOWS_VERSION...
DemoVersion defined.
NT_VERSION defined as: 5
WINDOWS_VERSION was not defined.
Done.
On lines 0 and 1,DemoVersionand NT_VERSIONare defined, with SW_VERSION
defined with the string 5. On line 12, the definition of DemoVersionis tested, and
because DemoVersionis defined (albeit with no value), the test is true and the string on
line 11 is printed.
On line 18 is the test that SW_VERSIONis not defined. Because SW_VERSIONis defined, this
test fails and execution jumps to line 21. Here the string 5 is substituted for the word
SW_VERSION; this is seen by the compiler as
cout << “SW_VERSION defined as: “ << 5 << endl;
Note that the first word SW_VERSIONis not substituted because it is in a quoted string.
The second SW_VERSIONis substituted, however, and thus the compiler sees 5 as if you
had typed 5 there.
Finally, on line 25, the program tests for WINDOWS_VERSION. Because you did not define
WINDOWS_VERSION, the test fails and the message on line 28 is printed.
Inclusion and Inclusion Guards ..........................................................................
You will create projects with many different files. You will probably organize your direc-
tories so that each class has its own header file (for example,.hpp) with the class decla-
ration and its own implementation file (for example,.cpp) with the source code for the
class methods.
Your main()function will be in its own .cppfile, and all the .cppfiles will be compiled
into .objfiles, which will then be linked into a single program by the linker.
Because your programs will use methods from many classes, many header files will be
included in each file. Also, header files often need to include one another. For example,
the header file for a derived class’s declaration must include the header file for its base
class.
Imagine that the Animalclass is declared in the file ANIMAL.hpp. The Dogclass (which
derives from Animal) must include the file ANIMAL.hppin DOG.hpp, or Dogwill not be
able to derive from Animal. The Catheader also includes ANIMAL.hppfor the same
reason.
OUTPUT
ANALYSIS