C++ joins two separate programming traditions (procedural language and object-oriented programming language) - It will be fun to learn.
Windows 95 (Folders, File, Work Space)
Unix
AS/400, MVS, etc
C++ Builder
C: Dennis Ritchie of Bell Laboratories in 1970
C++: Bjarne Stroustrup of Bell Labs in early 1980
The OOP approach to program design is to first design classes that accurately represent those things with which the program deals
Binding of data and methods into class definition
Inheritance, Polym, etc
Top-down / bottom-up vs OOD
ANSI C
Microsoft C++
IBM Visual Age C++
Borland C++
Java
Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 Source Code Compiler Object Code Linker Executable Code Startup Code Library Code
Source Code: <filename>.cpp
Different ways of Compliation and Linking
Running: MS-DOS prompt, Unix xterm, AS/400 call
#include <iostream.h> // Preprocessor directiveint main(void){cout << "The Classic Hello World" << endl;return 0;}
// General Formatint main(void) // Vs void main(void), int main(), etc{statementsreturn 0;}
// All the text behind this line will be commented
/* * ANSC C Style Comment * All the text between will be commented *//* * /* What about this ? */ * *//* * // How about this * */// Be careful on some platform, how long of a line it will take in general
C++, like C, uses a preprocessor.
It is a program that processes a source file before the main compilation take place.
#include <iostream.h> caues the preprocessor to add the contents of iostream.h file to your program
(Adding or replacing text is very common)Can add your own header files
The cout Object The Insertion Operator A String cout << "Hello World";
String "Hello World" inserted into output stream.
#include <iostream.h> // Preprocessor directiveint main(void){cout << "The Classic Hello World" << endl;return 0;}
/* * What about the following */#include <iostream.h> // Preprocessor directiveint main(void){cout << "The Classic Hello World" << endl;return 0;}
#include <iostream.h> // Preprocessor directiveint main(void){int myNumber;myNumber = 28;cout << "The Classic Hello World number is ";cout << myNumber;cout << "\n";return 0;}
cin >> myInput;
cout << "Input is " << myInput << "of Value" << endl;
Declaration with prototyping
void report (int);Implementation in the source code file
void report (int value) { cout << "Reporting a value of " << value << endl; }Calling the function
report (25);
This lab give a brief introduction on how to use the C++ compiler, standard header files, basic function, C++ statements and source code format.