DEF & FACTS! C + 1 = C++ C & C++ ARE MIDDLE LEVEL LANGUAGES INTRODUCTION BRIEF REVIEW OF C NEED OF C++ © arbit club cu 2010.

Slides:



Advertisements
Similar presentations
CPA: C++ Polymorphism Copyright © 2007 Mohamed Iqbal Pallipurath Overview of C++ Polymorphism Two main kinds of types in C++: native and user-defined –User-defined.
Advertisements

C++ data types. Structs vs. Classes C++ Classes.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction.
Introduction to C++CS-2303, C-Term Introduction to C++ CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
 2007 Pearson Education, Inc. All rights reserved C++ as a Better C; Introducing Object Technology.
C vs C++ CS-240 Data Structures Binghamton University Dick Steflik.
C++ fundamentals.
C + 1 == C++ ce153c Introduction2programming © 2006 NematAllah Ahmadyan.
Operator OverloadingCS-2303, C-Term Operator Overloading CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
Introduction to C++ Systems Programming.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
Introduction to C++ Systems Programming. Systems Programming: Introduction to C++ 2 Systems Programming: 2 Introduction to C++  Syntax differences between.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan Snd Term Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
Week 14 - Monday.  What did we talk about last time?  Introduction to C++  Input and output  Functions  Overloadable  Default parameters  Pass.
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.
Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
C ++ Basics by Bindra Shrestha sce.uhcl.edu/shresthab CSCI 3333 Data Structures.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction 15.2C A Simple Program: Adding Two Integers.
CSC1201: PROGRAMMING LANGUAGE 2 Aseel Al Hadlaq 2nd Term
C++ Programming Basic Learning Prepared By The Smartpath Information systems
I/O and Data Formatting Introduction to Class Concepts INFSY 307 Spring 2003 Lecture 3.
C++ Lecture 1 Friday, 4 July History of C++ l Built on top of C l C was developed in early 70s from B and BCPL l Object oriented programming paradigm.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 16: Introduction to C++
Review for Final Exam. Contents 5 questions (20 points each) + 1 bonus question (20 points) – Basic concepts in Chapters 1-4 – Chapters 5-9 – Bonus: Chapter.
Principles of Object-Oriented Software Development The language C++
Programming Language Principles Lecture 30 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Object-Oriented Programming.
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
Learners Support Publications Introduction to C++
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
CS116 SENEM KUMOVA METİN. Outline What is C++ ? Some features of C++ Input and Output Operations Manipulators C++ header files Namespaces and scope resolution.
Prepared by Andrew Jung. Contents A Simple program – C++ C++ Standard Library & Header files Inline Functions References and Reference Parameters Empty.
C++ Programming Michael Griffiths Corporate Information and Computing Services The University of Sheffield
Introduction to C++ programming Recap- session 1 Structure of C++ program Keywords Operators – Arithmetic – Relational – Logical Data types Classes and.
INPUT & OUTPUT 10/20/2016Department of Computer Science, UOM | Introduction | Fakhre Alam.
Chapter 15 - C++ As A "Better C"
Introduction to C++ (Extensions to C)
Operators in c++.
Introduction to C++ Systems Programming.
C++, OBJECT ORIENTED PROGRAMMING
Introduction to C++.
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.
Object-Oriented Programming Part 1
Object-Oriented Programming
Review for Midterm Exam
Review for Final Exam.
Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Review for Midterm Exam
Review for Midterm Exam
Principles of object – oriented programming UNIT-1 Chapter-1.
Review for Final Exam.
Review for Midterm Exam
Review for Midterm Exam
Chapter 15 - C++ As A "Better C"
Fundamental Programming
C++ data types.
C++ Object Oriented 1.
Introduction to Classes and Objects
Presentation transcript:

DEF & FACTS! C + 1 = C++ C & C++ ARE MIDDLE LEVEL LANGUAGES INTRODUCTION BRIEF REVIEW OF C NEED OF C++ © arbit club cu 2010

C++ C B A C was designed by Ritchi, Tompson, Kernighan It was fast, good & powerful but program’s maintance was a nightmare! Solution:... Object-Oriented Programming © arbit club cu 2010

DEF & FACTS! C + 1 = C++ Developed by- Bjarne Stroustrup © arbit club cu 2010 C++

DEF & FACTS! C & C++ ARE MIDDLE LEVEL LANGUAGES A better C A superset of C Created at Bell Labs in the 1980's and called C with Classes Adds additional features to improve the language Adds functions and features to support Object Oriented Programming (OOP) © arbit club cu 2010

OOP OBJECT ORIENTED PROGRAMING? © arbit club cu 2010

OBJECT ORIENTED PROGRAMING Objects (data and functions) are members of user-defined types called classes. A class definition is an extension of a C struct definition. It is made up of declarations of variables and of function prototypes to manipulate those variables. © arbit club cu 2010

OBJECT ORIENTED PROGRAMING The variables are typically declared to be private or protected and the functions are typically declared to be public. structs and classes actually are the same in C++ (both can have member functions or “methods”), but struct members are public by default and class members are private by default. © arbit club cu 2010

Basic concepts of OOP Inheritance Data abstraction Data encapsulation Polymorphism © arbit club cu 2010

Inheritance Inherit the capabilities of class from another class © arbit club cu 2010

Data abstraction Representing essential features without including the background details or explanations. © arbit club cu 2010

Data encapsulation Wrapping up of data & functions into single unit called class © arbit club cu 2010

Polymorphism More than one form © arbit club cu 2010

General things! C++ was originally developed to be the next version of C, not a new language. C + OOP Concepts = c++ © arbit club cu 2010

Similarities Data types Same start #include Same conditions same built-in operators on primitive types (+-/*……) © arbit club cu 2010

Similarities Same built-in control structures  if, for, while, switch …. must have a function names “main” to determine where the program starts functions are defined the same way © arbit club cu 2010

Differences C++ has function overloading (two functions may have the same name), in C function names must be unique. C++ has operator overloading (operators can be redefined to do other things) C++ uses “new” and “delete” for dynamic memory management, C uses “malloc” and “free” © arbit club cu 2010

Concepts! Printf-cout Scanf-cin Malloc-new Free-delete No use of %d,%c,%s etc …. © arbit club cu 2010

comparison # include int main(void) { printf(“Hello World\n”); return 0; } Simple c program to print hello world. © arbit club cu 2010

comparison C++ version! © arbit club cu 2010 #include int main(void) { cout << “Hello World\n”; return 0; }

Comparison! \n works both in c and c++ endl can be there in c++ instead of \n endl means end of line Stdio-standard input output Iostream-input output stream Cout-console output Cin-console input <<- output operator >>- input operator © arbit club cu 2010

Iostream iostream header file library #include contains definitions for several classes istreamostream fstreamios and their associated objects cincout cerrclog © arbit club cu 2010

Basics >> Extraction Operator extracts data from input stream. << Insertion Operator inserts data into output stream :: Scope Resolution Operator Cascading- Cout<<“the sum of 2 +5 = “<<2+5<<endl; Cin>>value1>>value2; Same starts from ‘main’ function © arbit club cu 2010

Conio.h for clrscr(); DATA TYPES Fundamentals Char,int,float,double Derived Array,functions,pointers,classes,structu res © arbit club cu 2010

Formatting tip Iomanip.h Setw(6) Sets width to 6 ______r Arithmetic operators +,-,/,*,% Increment/decrement operators ++,-- Relational, =,==,!= Logical ||,&&,! ? operator © arbit club cu 2010

setprecision(5) Gives Class math.h Some useful functions!  Ceil Ceil(1.03)- 2 Ceil(-1.03)- -1  Exp Exp(2)e*e  Floor Floor(1.03)1 Floor(-1.03)-2  Log log(1.0)gives natural log for 1.0  Pow  Power(3.0,0) gives 1  Power(4,2)gives 16 © arbit club cu 2010

Math.h Sqrt Sqrt(81.0)gives 9 These are some useful math.h functions you can scan books for more functions! © arbit club cu 2010

Selection statements! If(condition) Statement; Else(condition) Statement; Else Statement; © arbit club cu 2010

Alternative to if ? Expression ? Expression1 : expression2; E.g. a>b?a=10:b=20; © arbit club cu 2010

switch Switch(ch) { case 1: // break; case 2:// break; case3:// break; default:// } © arbit club cu 2010

Loops!! While Do while For © arbit club cu 2010

Character functions If (isalpha(ch)) Nonzero-alphabet Zero-Otherwise If (isdigit(ch)) Nonzero-digit Zero-Otherwise If (islower(ch)) Nonzero-if lowercase letter Zero-Otherwise If (isupper(ch)) Nonzero-alphabet Zero-Otherwise Ch=‘a’; Cout<<toupper(ch) Gives- A Cout<<tolower(ch) Gives- a © arbit club cu 2010

String functions! Char *str1=“one”; Char *str2=“two”; Strcat(str1,str2) Cout<<str1; //onetwo © arbit club cu 2010

Comparison function Char *str1=“ace”; Char *str2=“bag”; Strcmp(str1,str2) //returns –ve value Strcmp(str2,str1) //returns +ve value © arbit club cu 2010

Copying and length Strcpy(str2,str1) //value of str1 into str2 Strlen(“vikrant”) would give 7 © arbit club cu 2010

Function overloading!! Complete reference pg-275 Constructors-283 Classes basics-290 © arbit club cu 2010

THANKYOU! THANKYOU DOUBTS!! © arbit club cu 2010