Dr. Md. Humayun Kabir CSE Department, BUET

Similar documents
AN OVERVIEW OF C++ 1

Unit 1 : Principles of object oriented programming

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

Understanding main() function Input/Output Streams

Fast Introduction to Object Oriented Programming and C++

C++ basics Getting started with, and Data Types.

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Computer Programming

Introduction to C++ Introduction to C++ 1

Data Structures and Programming with C++

6.096 Introduction to C++ January (IAP) 2009

(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University

Introduction to C++ Systems Programming

C++ As A "Better C" Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.

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

C++ Quick Guide. Advertisements

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Introduction to C++ (Extensions to C)

4. Structure of a C++ program

Object Orientated Analysis and Design. Benjamin Kenwright

CSCE 110 PROGRAMMING FUNDAMENTALS

A SHORT COURSE ON C++

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

CE221 Programming in C++ Part 1 Introduction

Object Oriented Programming. Solved MCQs - Part 2

September 10,

Chapter 2: Overview of C++

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

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

Partha Sarathi Mandal

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

C++ Programming for Non-C Programmers. Supplement

CSE 303: Concepts and Tools for Software Development

Your First C++ Program. September 1, 2010

Chapter 1 Introduction to Computers and C++ Programming

Cours de C++ Introduction

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Fundamentals of Structured Programming

COMP322 - Introduction to C++ Lecture 01 - Introduction

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

1 Unit 8 'for' Loops

Computer Programming : C++

Programmazione. Prof. Marco Bertini

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Introduction to C++ IT 1033: Fundamentals of Programming

CSI33 Data Structures

Scientific Computing

Absolute C++ Walter Savitch

UEE1302 (1102) F10: Introduction to Computers and Programming

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

EL2310 Scientific Programming

2. Functions I: Passing by Value

Fundamentals of Programming. Lecture 19 Hamed Rasifard

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Interview Questions of C++

C++ Programming Classes. Michael Griffiths Corporate Information and Computing Services The University of Sheffield

CSE 333. Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington

EP241 Computer Programming

Inheritance, and Polymorphism.

CSE 333 Lecture 9 - intro to C++

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Data Structures using OOP C++ Lecture 3

A A B U n i v e r s i t y

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Get Unique study materials from

Programming Language. Functions. Eng. Anis Nazer First Semester

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

Streams. Ali Malik

Lab 8 The Stack (LIFO) Structure

CS11 Introduction to C++ Fall Lecture 1

Introduction to Programming using C++

Strings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Tutorial-2a: First steps with C++ programming

Data Structures using OOP C++ Lecture 6

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

Object Oriented Design

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

CS 11 C++ track: lecture 1

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:

CMPS 221 Sample Final

1. Software Systems Complexity, OO Paradigm, UML

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

TEMPLATE IN C++ Function Templates

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

CS 376b Computer Vision

CS

Short Notes of CS201

Object-Oriented Programming

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

Engineering Problem Solving with C++, Etter

CMSC 202 Midterm Exam 1 Fall 2015

W3101: Programming Languages C++ Ramana Isukapalli

3. Functions. Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.

Why C++? C vs. C Design goals of C++ C vs. C++ - 2

Cpt S 122 Data Structures. Introduction to C++ Part II

Transcription:

C++ Dr. Md. Humayun Kabir CSE Department, BUET

History of C++ Invented by Bjarne Stroustrup at Bell Lab in 1979 Initially known as C with Classes Classes and Basic Inheritance The name was changed to C++ in 1983 Function Overloading and Virtual Functions In 1985, Stroustrup's reference to the language entitled The C++ Programming Language was published Static Members and Inheritance from several Classes were included in 1989. 2

History of C++ (cont..) In 1990, The Annotated C++ Reference Manual was released and Borland's Turbo C++ compiler was released as a commercial product. In 1998, the C++ standards committee published the first international standard for C++ ISO/IEC 14882:1998, known as C++98. The Standard Template Library was included in C++98. 3

History of C++ (cont..) Problems reported with C98 standard were revised in 2003 and the changed language is known as C++03. In 2011, the new C++ standard, C++11, has been published. 4

History of C++ (cont..) 5 Some new features included in C++11 are regular expression a comprehensive randomization library a new C++ time library atomics support a standard threading library (which both C and C++ were lacking) a new for loop syntax providing functionality similar to foreach loops in certain other languages auto keyword new container classes better support for unions and array-initialization lists variadic templates. t

C and C++ C++ is the superset of C C++ includes everything of C and adds OOP support In addition C++ contains many improvements and features to make the language better than the original C. 6

New Style C++ Headers #include <iostream> #include <vector> #include <string> #include <cstring> Do not have.h extension and do not specify file name Specify standard identifiers that are mapped to files by the compiler C++ still support C-style header files, e.g., #include <stdio.h> #include <string.h> 7

C++ Namespace 8 A namespace is a declaration region It localizes the names of identifiers to avoid name collisions In C, the names of the library functions and other such items are not localized by any namespace, instead, they are implicitly placed into global namespace For this reason, C library functions with C-style headers can simply be used in programs without any special arrangement

C++ Namespace (cont ) In C++, the names of the library functions and other such items related to new-style headers are defined, i.e., localized, in the std namespace In order to use the library functions with newstyle headers we need to bring std namespace into visibility using namespace std; 9

C++ Console I/O 10 In C++ I/O is performed using I/O operator instead of I/O functions The output operator is insertion operator, << The input operator is extraction operator, >> In order to use either insertion (<<) or extraction (>>) operator programs must begin with the followings #include <iostream>.. using namespace std;

C++ Console I/O (cont ) Insertion operator (<<) is associated with cout, a predefined stream linked to the console output (monitor) cout<< Hello! ; Extraction operator (>>) is associated with cin, a predefined stream linked to the console input (keyboard) int num; cin>>num; 11

C++ Console I/O Code #include <iostream> using namespace std; int main() { int num; cout<< Enter an integer value: ; cin>>num; cout<< Your entered number is <<num<< \n ; return 0; } 12

C++ Console I/O Code Output Enter an integer value: 100 Your entered number is 100 13

Concepts in Object-Oriented Programming g Encapsulation Information hiding Objects contain their own copies of data and functions (algorithms) Polymorphism A single name can have multiple meanings depending on its context Inheritance Writing reusable code Objects can inherit characteristics from other objects 14

C++ Features Supports data security Prevents accidents with data Helps code reuse. Lets you use operators the way you like. Allows multiple functions/operators with the same name. Courtesy: Piyush Kumar, Florida State University 15

When to use C++ Large projects System applications Graphics Data Structures Speed is an issue Changes in functionality required Need exceptions and error handling Want to speed up your scripts Courtesy: Piyush Kumar, Florida State University 16

When not to use C++ Small system programs (use C) Fast prototyping (use Visual Basic/Cold Fusion) Web-based applications (use PHP/Perl/Python) Courtesy: Piyush Kumar, Florida State University 17

cout<< Thank You <<endl; cout<< Have a Good Day <<endl; 18