JMU
Developing in C/C++
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Applications in C/C++
Overview of the Development Process
images/cpp_development-process.gif

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.

The Preprocessor
The Preprocessor - Text Replacement
The Preprocessor - Conditional Compilation
The Preprocessor - Conditional Compilation (cont.)

An Example

    #ifdef VERBOSE
        cout << "Inside factorial: n = " << n  << "\n";
    #endif
    
The Preprocessor - Conditional Compilation (cont.)
The Preprocessor - Including Other Files
The Preprocessor - Including Other Files (cont.)
The Preprocessor - Including Other Files (cont.)

Account.h

    #ifndef Account_h
    #define Account_h
    .
    .
    .
    #endif
  
The Preprocessor - Including Other Files (cont.)
The Preprocessor - Including Other Files (cont.)

Account.h

    #ifndef edu_jmu_cs_bernstdh_Account_h
    #define edu_jmu_cs_bernstdh_Account_h
    .
    .
    .
    #endif
  
The Preprocessor - Including Other Files (cont.)
The Compiler
The Compiler (cont.)
The Linker
The Linker (cont.)
Executing/Running a Program
Practical Issues