CPSC 427a: Object-Oriented Programming

Similar documents
CPSC 427a: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

ENERGY 211 / CME 211. Evolution

2.1 Why did C need a ++?

6.096 Introduction to C++ January (IAP) 2009

Evaluation Issues in Generic Programming with Inheritance and Templates in C++

CPSC 427: Object-Oriented Programming

Level 3 Computing Year 2 Lecturer: Phil Smith

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

CPSC 427: Object-Oriented Programming

AN OVERVIEW OF C++ 1

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

September 10,

Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Systems Programming/ C and UNIX

CPSC 427: Object-Oriented Programming

CPSC 427a: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

MA400: Financial Mathematics

Scientific Computing

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access.

Study Guide to Exam 2

Lecturer: William W.Y. Hsu. Programming Languages

Lecture 2 Tao Wang 1

Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות

Introduction to C++ IT 1033: Fundamentals of Programming

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Object-Oriented Principles and Practice / C++

B16 Object Oriented Programming

Wednesday, November 5

Lecture 1: Overview of Java

Computational Physics Operating systems

CS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Chapter 5 Object-Oriented Programming

CPSC 427: Object-Oriented Programming

CPSC 427: Object-Oriented Programming

CPSC 427a: Object-Oriented Programming

Programming II. Modularity 2017/18

Object-Oriented Principles and Practice / C++

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

Chapter 9 :: Data Abstraction and Object Orientation

An Introduction to C++

Engr. M. Fahad Khan Lecturer Software Engineering Department University Of Engineering & Technology Taxila

Unit 1 : Principles of object oriented programming

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes

C++ (Non for C Programmer) (BT307) 40 Hours

STRUCTURING THE PROGRAM

Object-Oriented Programming

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

The Ocarina Tool Suite. Thomas Vergnaud

Introduction to C++ with content from

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

CSc Introduction to Computing

Modules, Structs, Hashes, and Operational Semantics

Chapter 10 :: Data Abstraction and Object Orientation

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

CS 376b Computer Vision

CSCI312 Principles of Programming Languages!

PROGRAMMING IN C++ COURSE CONTENT

Object-Oriented Principles and Practice / C++

Opal. Robert Grimm New York University

UNIV AT CHAPEL HILL DEPT OF COMPUTER SCIENCE J M COGGINS N K-B0,80 UNCLASSIFIED F/G 12/5 idi

Certified Core Java Developer VS-1036

Object-Oriented Principles and Practice / C++

Principles of Programming Languages. Lecture Outline

Object Oriented Programming. Solved MCQs - Part 2

Fall Lecture 3 September 4. Stephen Brookes

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

CS349/SE382 A1 C Programming Tutorial

Chapter 15 - C++ As A "Better C"

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011

CS11 Intro C++ Spring 2018 Lecture 2

CSC 330 Object-Oriented Software Design REUSABILITY

Chapter 3 Objects, Types, and Values

Modular Programming. Prof. Clarkson Fall Today s music: "Giorgio By Moroder" by Daft Punk

Outline. 1 About the course

Fast Introduction to Object Oriented Programming and C++

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Multimedia-Programmierung Übung 3

Review&Preview 1/23/15, 4:08:07 PM 1. 3rd edition - standardized, and standard library allows programmer to start from a higher level

Size, Alignment, and Value Ranges of Data Types. Type Synonym Size Alignment Value Range. BYTE INTEGER*1 8 bits Byte

Swift. Introducing swift. Thomas Woodfin

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

CPS221 Lecture: Operating System Functions

Special Topics: Programming Languages

Advanced Database Applications. Object Oriented Database Management Chapter 13 10/29/2016. Object DBMSs

Programming in C and C++

Practical C++ Programming

Operational Semantics. One-Slide Summary. Lecture Outline

Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, Vol. 2. pp Virtuoso Virtuality

Transcription:

CPSC 427a: Object-Oriented Programming Michael J. Fischer Lecture 2 September 6, 2011 CPSC 427a 1/14

C++ Overview C++ Goals Comparison of C and C++ Tools Example Insertion sort C version C++ version CPSC 427a 2/14

C++ Language Design Goals CPSC 427a 3/14

C++ Goals Why did C need a ++? Chapter 2 of Exploring C++ 1. C was designed and constructed a long time ago (1971), as a language for writing Unix. 2. The importance of data modeling was very poorly understood at that time. 3. Data types were real, integer, character, and array, of various sizes and precisions. 4. It was important for a C to be powerful and flexible, but not to have clean semantics. 5. Nobody talked about portability and code re-use. Today, we demand much more from a language. CPSC 427a 4/14

C++ Goals C++ was Designed for Modeling Design goals for C++ (Bjarne Stroustrup) 1. Provide classes (replacing structs) as a means to model data. 2. Let a class encapsulate data, so that its implementation is hidden from a client program. 3. Permit a C++ program to link to libraries from other languages, especially FORTRAN. 4. Produce executable code that is as fast as C, unless run-time binding is necessary. 5. Be fully compatible with C, so that C programs could be compiled under a C++ compiler and still work properly. CPSC 427a 5/14

C++ Goals General properties of C++ Widely used in the real world. Close to the machine and capable of producing efficient code. Gives a programmer fine control over the use of resources. Supports the object-oriented programming paradigm. Supports modularity and component isolation. Supports correctness through privacy, modularity, and use of exceptions. Supports reusabale code through derivation and templates. CPSC 427a 6/14

Comparison of C and C++ C++ Extends C C++ grew out of C. Goals were to improve support for modularity, portability, and code reusability. Most C programs will compile and run under C++. C++ replaces several problematic C constructs with safer versions. Although most old C constructs will still work in C++, several should not be used in new code where better alternatives exist. Example: Use Boolean constants true and false instead of 1 and 0. CPSC 427a 7/14

Comparison of C and C++ Some Extensions in C++ Comments // (now in C99) Executable declarations (now in C99) Type bool (now in C99) Enumeration constants are not synonyms for integers Reference types Definable type conversions and operator extensions Functions with multiple methods Classes with private parts; class derivation. Class templates An exception handler. CPSC 427a 8/14

Tools Tools Low-level: Command line tools A text editor such as emacs or vi. The compiler suite: g++. Project management: make High-level: Integrated Development Environments (IDEs) Integrate various low-level tools Facilitate development cycle CPSC 427a 9/14

Tools Recommended IDE s The following are all open source and are installed on the Zoo. Geany Easy to use. Good for small projects. CodeBlocks Good general purpose IDE. Many advanced features, well-engineered, but not well-supported on Mac OS X. Eclipse/CDT Powerful, well-supported IDE, somewhat brittle, but getting better all the time. CPSC 427a 10/14

Example CPSC 427a 11/14

Insertion sort Generic Insertion Sort Two implementations of simple insertion sort: 1. C version: Written in object-oriented style to the extent possible in C. 2. C++ version: Similar code but with C++ support CPSC 427a 12/14

C version C version See code demo 02-InsertionSortC. CPSC 427a 13/14

C++ version C++ version See code demo 02-InsertionSortCpp and following notes. CPSC 427a 14/14