1 / 15

Computer programming

Computer programming. Introduction to C++. History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed by Bjarne Stroustrup at Bell Labs Bell Lab's internal standard language for system programming

santos
Download Presentation

Computer programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer programming

  2. Introduction to C++ History • Merges notions from Smalltalk and notions from C • The class concept was borrowed from Simular67 • Developed by BjarneStroustrup at Bell Labs • Bell Lab's internal standard language for system programming • Keeps C's original executing speed while enabling object-oriented programming (OOP).

  3. History of C and C++ • C evolved from two other programming languages, BCPL and B • ANSI and C • The “American National Standards Institute “Established worldwide standards for C programming • 1980: “C with Classes” Improve program structure. Maintain run-time efficiency. • 1985: C++ 1.0 • 1995: Draft standard.

  4. History of C and C++ • Provides capabilities for object-oriented programming. • What is Objects? • Objects are reusable software components that model things in the real world” • Object-oriented programs are easy to understand, correct and modify

  5. C versus C++ • Claimed advantages: 1. Faster development time (code reuse) 2. Creating/using new data types is easier 3. Memory management: easier more transparent 4. Stricter syntax & type checking => less bugs 5. Data hiding easier to implement 6. OO concepts in C++

  6. Types of programming • Procedural Programming. • Modular Programming. • Object-Oriented Programming.

  7. Procedural Programming • The original programming paradigm is “Decide which procedures you want; use the best algorithms you can find” • The focus is on the processing - the algorithm needed to perform the desired computation. • Languages support this paradigm by providing facilities for passing arguments to functions and returning values from functions.

  8. Procedural Programming • The literature related to this way of thinking is filled with discussion of ways to pass arguments, ways to distinguish different kinds of arguments, different kinds of functions, etc.

  9. Modular Programming • The emphasis in the design of programs has shifted from the design of procedures and toward the organization of data. “Decide which modules you want; partition the program so that data is hidden in modules” • A module is a set of related procedures with data they manipulate. • This paradigm is also known as data-hiding principles

  10. Object-Oriented Programming Objects: • Reusable software components that model real world items. • Meaningful software units - Date objects, time objects, pay check objects, invoice objects, audio objects, video objects, file objects, record objects, etc. - Any noun can be represented as an object. • It is claimed that this is more understandable, better organized and easier to maintain than procedural programming.

  11. C++ OOP Features • C++ is a hybrid language (can program in procedural or OO fashion or both) • Concepts for Object Orientation: • Encapsulation (Data-hiding) • Inheritance • Polymorphism • Ability to be dynamic (concept of objects)

  12. Program is created in the editor and stored on disk. Preprocessor program processes the code. Compiler creates object code and stores it on disk. Compiler Linker links the object code with the libraries, creates a.out and stores it on disk Primary Memory Loader Loader puts program in memory. Primary Memory CPU takes each instruction and executes it, possibly storing new data values as the program executes. Preprocessor Linker Editor Disk Disk Disk Disk Disk CPU . . . . . . . . . . . . A Typical C++ Environment • Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute

  13. C++ INPUT AND OUTPUT • C++ programs make use of a library called iostream (input / output stream library). • Input/output • cin • Standard input stream • An input stream gets data bytes from some input device and routes them to a program. • Normally keyboard

  14. C++ INPUT AND OUTPUT • Cout • Standard output stream • An output stream is something that takes character data and gets them to an output device. • Normally computer screen • cerr • Standard error stream • Display error messages

  15. First program // my first program in C++ #include <iostream> using namespace std; int main () { cout << "Hello World!"; Return o; } Hello World!

More Related