1 chapter-01 introduction to c++ programming language

12
1 Chapter-01 Introduction to C++ Programming Language

Upload: darcy-lester

Post on 01-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Chapter-01 Introduction to C++ Programming Language

1

Chapter-01

Introduction to C++ Programming Language

Page 2: 1 Chapter-01 Introduction to C++ Programming Language

2

C++ History

• 1972 : Dennis Ritchie at Bell Labs designs C and 90% of UNIX is then written in C

• Late 70’s : OOP becomes popular

• Bjarne Stroustrup at Bell Labs adds features to C to form “C with Classes”

• 1983 : Name C++ first used

• 1998 : ISO/ANSI standardization of C++

Page 3: 1 Chapter-01 Introduction to C++ Programming Language

3

Three C++ Program Stages

other code from libraries,

etc.

other code from libraries,

etc.

written in machine language

written in machine language

written in machine language

written in machine language

written in C++

written in C++

via compiler via linker

SOURCE OBJECT EXECUTABLE

myprog.cpp myprog.obj myprog.exe

Page 4: 1 Chapter-01 Introduction to C++ Programming Language

4

Translating a source file into an executable file

Source Code is entered with a text editor by the programmer.

Source Code

Preprocessor

Modified Source Code

Compiler

Object Code

Linker

Executable Code

#include <iostream.h>void main(void){

cout<<“Hello World”;}

Object Code for other functions

Page 5: 1 Chapter-01 Introduction to C++ Programming Language

5

Running a Program

Output

Program Data

Computer

Page 6: 1 Chapter-01 Introduction to C++ Programming Language

6

C++ Program Translation

• Compile

• Execute

C++ Program Data for C++ Program

C++ Compiler

Machine-LanguageInstructions

Computer Executionof Machine-Language Instructions

Output of C++ Program

Page 7: 1 Chapter-01 Introduction to C++ Programming Language

C++ Program Data for C++ Program

C++ Compiler

Machine-LanguageInstructions

Computer Executionof Machine-Language Instructions

Output of C++ Program

Computer

Linker

Previously Compiled Helper Programs

C++ Program Translation Including Linker

Page 8: 1 Chapter-01 Introduction to C++ Programming Language

8

Java Programming Language

• achieves portability by using both a compiler and an interpreter

• first, a Java compiler translates a Java program into an intermediate bytecode--not machine language

• then, an interpreter program called the Java Virtual Machine (JVM) translates a single instruction in the bytecode program to machine language and immediately

runs it, one at a time

Page 9: 1 Chapter-01 Introduction to C++ Programming Language

9

Java Program Translation

• Both Compilation and Interpretation

• Intermediate Code:“Byte Code”

– portable low-level code

– similar to assembly code,but hardware independent

– invisible to Java programmer

• Interpreter translates from generic byte code to hardware-specific machine code

Java Program Data for Java Program

Java Compiler

Byte-CodeProgram

Byte-Code Interpreter

Machine-LanguageInstructions

Computer Executionof Machine-Language Instructions

Output of Java Program

JavaVirtual

Machine

Page 10: 1 Chapter-01 Introduction to C++ Programming Language

Java Program Data for Java Program

Java Compiler

Byte-CodeProgram

Byte-Code Interpreter

Machine-LanguageInstructions

Computer Executionof Machine-Language Instructions

Output of Java Program

JavaVirtual

Machine

Linker

Previously Compiled Helper Programs

Java Program Translation Including Linker

Page 11: 1 Chapter-01 Introduction to C++ Programming Language

11

Learning C++

• There are two pieces to learning the C++ world.

– First, is learning the C++ language itself.

– Second, is learning how to use the classes and functions in the C++ standard library.

Page 12: 1 Chapter-01 Introduction to C++ Programming Language

12

Procedural and Object-Oriented Programming• Procedural programming and object-

oriented programming are two ways of thinking about software development and program design.