Programming Language C++ Xulong Peng CSC415 Programming Languages.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Programming Languages and Paradigms The C Programming Language.
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
C++ Programming Languages
C++ Basics Variables, Identifiers, Assignments, Input/Output.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Jay Summet CS 1 with Robots IPRE Python Review 1.
ISBN Chapter 7 Expressions and Assignment Statements.
Reasons to study concepts of PL
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction.
CSE 452: Programming Languages Expressions and Control Flow.
1 Midterm Review COMP 102. Tips l Eat a light meal before the exam l NO electronic devices (including calculators, dictionaries, phones, pagers, etc.)
ISBN Lecture 07 Expressions and Assignment Statements.
Operator OverloadingCS-2303, C-Term Operator Overloading CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
C++ Yeting Ge.
Programming Language Concepts
Language Evaluation Criteria
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
Imperative Programming
1-1 University of Hail College of Computer Science and Engineering Department of computer Science and Software Engineering Course: ICS313: Fundamentals.
Ryan Chu. Arithmetic Expressions Arithmetic expressions consist of operators, operands, parentheses, and function calls. The purpose is to specify an.
CS 363 Comparative Programming Languages Expressions and Assignment Statements.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Fundamentals of C and C++ Programming Control Structures and Functions.
General Features of Java Programming Language Variables and Data Types Operators Expressions Control Flow Statements.
Introduction to C++ Systems Programming. Systems Programming: Introduction to C++ 2 Systems Programming: 2 Introduction to C++  Syntax differences between.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 3: Objects, Types, and Values 1 Based on slides.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
Review C Language Features –control flow –C operators –program structure –data types –I/O and files Problem Solving Abilities.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
PLLab, NTHU,Cs2403 Programming Languages Expression and control structure Kun-Yuan Hsieh Programming Language Lab., NTHU.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Programming Languages and Paradigms Imperative Programming.
Arithmetic Expressions
COMPUTER PROGRAMMING. variable What is variable? a portion of memory to store a determined value. Each variable needs an identifier that distinguishes.
Looping and Counting Lecture 3 Hartmut Kaiser
Chapter 7 © 1998 by Addison -Wesley Longman, Inc Arithmetic Expressions - Their evaluation was one of the motivations for the development of the.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Principles of Object-Oriented Software Development The language C++
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
7-1/27 Chapter 7 Expressions and Assignment Statements Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Chapter 15 - C++ As A "Better C"
C++ Lesson 1.
Information and Computer Sciences University of Hawaii, Manoa
7.2 Arithmetic Expressions
Python Review 1.
Chapter 1.2 Introduction to C++ Programming
Introduction to C++ Systems Programming.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Chapter 3: Understanding C# Language Fundamentals
Final Review In Text: Chapters 1-3, 5-11,
Final Review In Text: Chapters 1-3, 5-12,
Final Review In Text: Chapters 1-3, 5-16.
Final Review In Text: Chapters 1-3, 5-16.
Languages and Compilers (SProg og Oversættere)
Final Review In Text: Chapters 1-3, 5-16.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Final Review In Text: Chapters 1-3, 5-16.
Midterm Review In Text: Chapters 1-3, 5-11, 15.
C Language B. DHIVYA 17PCA140 II MCA.
Presentation transcript:

Programming Language C++ Xulong Peng CSC415 Programming Languages

Outline History Design, Syntax and Semantics Evaluation Code demonstration

History of C++ C++ was developed from C Written by Dr. Bjarne Stroustrup from Bell Labs in 1979 “C and classes” and then named C++ Standardized by ISO in  C++98, C++03, C++11 and C++14 New features: OOP, addition safety, operator overloading, templates, exception handling

Name, Binding and Scopes Name(Identifiers) Letter, digits and underscore case-sensitive Keywords(i.e. int, while, using, for, namespace) Binding Static binding and dynamic binding C++ supports OOP and implements dynamic binding

Name, Binding and Scopes (continues) C++’s scopes  Local scope  Class scope  Namespace scope  Global scope

Data Type (C++ is a typed language) numeric types (integer, floating and double) Boolean (true and false) character void type pointer (*pt) array User-defined (struct, enum, class)

Data Type Conversion Narrowing conversion (double -> float) Widening conversion (int -> float) Implicit or explicit conversion

Expression and Assignment Statements C++ provides a rich set of operators  unary, binary and ternary operators ++, --, +, - and ? :  support % operator (only apply to integer)  relational operators operator associativity and precedence

Associativity and Precedence (source: Deitel and Deitel, 2012)

Assignment Statements Expression int count = 10; Compound statements One or more individual statements in {} Control statements If …else, loop and switch

Control Structure Sequence Statement Selection Statement Iterative (or loop) Statement C++ provides break, continue, goto and return to alter the flow of control

Selection Statements Selection statements offer a choice between two or more execution.  If statement  If…else statement  Switch statement

Repetition Statements for (counter init; condition; counter update) While (condition expression){statements} do { statements to execute} while (condition); C++11 also provide a rang-based for loop

Functions C++ uses prototype as a function declaration Function definition: typeName functionName (parameter list) { statements; return;}

Functions C++ parameters can be passed by: value, reference or const-reference Example: double avg (const vector & arr, int n, bool & errorFlag); An inline function to speed up execution Function overloading template

C++’s OOP features Encapsulation  Supports build-in data type and user-define ADT(class) Inheritance  Provides single and multiple inheritance Polymorphism  Supports dynamic binding

Exception Handling try … catch block In C++, an exception is either a user or a library defined class Must be explicitly raised using throw

Concurrency Original C++ standard only supports single thread programming C++11 adds concurrency in the form of C++11 model C++11 uses a thread library for starting and managing threads

Evaluation of C++ Readability  C++ is a large language which complicates its readability  User defined operator overloading (aids and harms)  Supports numeric as Boolean expression affects readability.  Case sensitive, good control structures, more flexible iteration statements helps readability  Use of OOP improves its readability and writability

Evaluation of C++ Writability  Its writability is highly associated with its readability  C++ has rich data type and supports abstraction improves writability  Efficient expression helps writability  Flexible and efficient control statements  C++’s template improves writability

Evaluation of C++ Reliability  It is reliable if used carefully  flexibility and efficiency vs. reliability (not strongly typed and does not have strict type checking)  The use of pointer type is very flexible but could cause dangling pointer and memory leaking  Abstraction and information hiding improves its reliability  Exception handling improves its reliability

Evaluation of C++ Cost  Hard to learn as it is a large language.  The cost of writing C++ depends on applications. Generally, it is easy to write as syntax is very straightforward.  Backward compatible with C (low cost for C programmer)  Cheaper or free IDE reduces cost for training  Inexpensive compliers decrease the cost of compilation and execution  Flexibility and efficiency speed up execution  The cost on reliability and maintenance with trade-offs.

Some Code Examples

Shape 2 D 3 D Circle Square Sphere Cube

Q & A