LEC02-OverviewC++ - COEN 243 WINTER 2007 Instructor: Dr....

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Instructor: Dr. Abdelwahab Hamou-Lhadj Lecture 2 Overview of C++ COEN 243 WINTER 2007
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The content of some of these slides is based on Chapter 2 of the textbook: “Small C++ How to Program 5/E” by Harvey and Paul Deitel Print ISBN: 0-13-185758-4 © Copyright Notice
Background image of page 2
1       // Fig. 1.2: fig01_02.cpp 2       // A first program in C++. 3       4       5       6       int 7       { 8       std::cout << "Welcome to C++!\n" ; 9       10     // indicate that program ended successfully 11     12     } // end function main A Simple Program: Printing a Line of Text Welcome to C++! Single-line comments. Preprocessor directive to include input/output stream <iostream> . appears exactly once in every C++ Function main returns an integer value. Left brace { begins function body. Corresponding right ends function body. Statements end with a semicolon ; . Name cout belongs to namespace std . Stream insertion operator. Keyword return is one of several means to exit function; value 0 indicates program terminated successfully.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basics of a Typical C++ Environment Phases of C++ Programs: 1. Edit 2. Preprocess 3. Compile 4. Link 5. Load 6. Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory Disk Disk Disk Disk Disk
Background image of page 4
Comments and Preprocessor Directives Comments Document programs Improve program readability Ignored by compiler Single-line comment Begin with // Preprocessor directives Processed by preprocessor before compiling Begin with #
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
std:cout Standard output stream object std::cout “Connected” to screen
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

LEC02-OverviewC++ - COEN 243 WINTER 2007 Instructor: Dr....

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online