|
Developing in C/C++
An Introduction |
|
Prof. David Bernstein |
| Computer Science Department |
| bernstdh@jmu.edu |
A Note for Java Programmers: Java does not have a linker and does not (normally) produce executable files. Instead, the compiler creates byte code that is executed by an interpreter.
:
#define statement that can be used for more
complicated substitutions. It is best to avoid the use of
"macros" of this kind.
:
#define
statement (e.g., #define VERBOSE) and
is undefined using the #undef statement
(e.g.,#undef VERBOSE)
#ifdef VERBOSE
cout << "Inside factorial: n = " << n << "\n";
#endif
-D
option#ifndef statement (if not defined)
and the #else statement#include
statements #include statements can be nested
(e.g., the file test.cpp can #include
test.h and test.h can
#include
myconstants.h)#include statements
Account.h
#ifndef Account_h
#define Account_h
.
.
.
#endif
Account.h
#ifndef edu_jmu_cs_bernstdh_Account_h
#define edu_jmu_cs_bernstdh_Account_h
.
.
.
#endif
#include unrelated files in the
.h file or the .cpp file?#include it in the .h
file whereas if it is needed only for implementation
then #include it in the
.cpp file)| Lexical Analysis | Identification of tokens (e.g., keywords, identifiers, etc...) (this process is sometimes called scanning) |
| Syntactic Analysis | Identification of grammatical and ungrammatical phrases. (this process is called parsing) |
| Code Generation | Production of object or machine code (or some kind of intermediate code) from the "parse tree" |
| Optimization | Improvement of code to make it smaller or faster (or to achieve some other objective) |
sqrt
function, the compiler only needs to know the
signature of this function (e.g., what it is
passed and what it returns)#include directive)