Sayed Ahmed Just E.T.C Technologies Inc. Just E.T.C. Education Inc.

Slides:



Advertisements
Similar presentations
C/c++ 4 Yeting Ge.
Advertisements

IOStreams CNS 3370 Copyright 2003, Fresh Sources, Inc.
File I/O in C++. Using Input/Output Files A computer file is stored on a secondary storage device (e.g., disk);is stored on a secondary storage device.
I/O and Program Control Statements Dick Steflik. Overloading C++ provides two types of overloading –function overloading the ability to use the same function.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
17 File Processing. OBJECTIVES In this chapter you will learn:  To create, read, write and update files.  Sequential file processing.  Random-access.
1 File I/O In C++, I/O occurs in streams. A stream is a sequence of bytes Each I/O device (e.g. keyboard, mouse, monitor, hard disk, printer, etc.) receives.
Chapter 3: Input/Output
C++ fundamentals.
Object Oriented Programming using VC++. Introduction Program – Set of instruction written in a high level language High level language used for writing.
Object Oriented Programming using C++. Overview Problem Solving Features of an OOL Basic Syntax Programming Paradigms.
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
C++ for Engineers and Scientists Second Edition Chapter 8 I/O File Streams and Data Files.
File I/O ifstreams and ofstreams Sections 11.1 &
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.
FILE HANDLING IN C++.
STL List // constructing lists #include int main () { // constructors used in the same order as described above: std::list first; // empty list of ints.
File handling in C++ BCA Sem III K.I.R.A.S. Using Input/Output Files Files in C++ are interpreted as a sequence of bytes stored on some storage media.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Monday, Mar 31, 2003Kate Gregory with material from Deitel and Deitel Week 12 Labs 4 and 5 are back File IO Looking ahead to the final.
Fundamental File Processing Operations C++
C++ Programming Part 2 Michael Griffiths Corporate Information and Computing Services The University of Sheffield
C++ FILE I/O.
FILE I/O IN C++. Using Input/Output Files A computer file  is stored on a secondary storage device (e.g., disk);  is permanent;  can be used to provide.
Student Book Input / Output in C++
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Lecture 19 CIS 208 Wednesday, April 06, Welcome to C++ Basic program style and I/O Class Creation Templates.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 21 - C++ Stream Input/Output Basics Outline 21.1Introduction 21.2Streams Iostream Library.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 12 Advanced File Operations.
File I/O Version 1.0. Topics I/O Streams File I/O Formatting Text Files Handling Stream Errors File Pointers.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
CS  Inserters and Extractors  Stream State  Files Streams  String Streams  Formatting  Manipulators  Internationalization.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due Friday, 7pm. RAD due next Friday. Presentations week 6. Today: –More details on functions,
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Input/Output CSci 588: Data Structures, Algorithms and Software Design Fall 2011 All material not from online sources copyright © Travis Desell, 2011
File Processing Files are used for data persistance-permanent retention of large amounts of data. Computer store files on secondary storage devices,such.
Learners Support Publications Working with Files.
CSCI 333 Data Structures I/O with C++ 20 October, 2003.
Binary Files. Text Files vs. Binary Files Text files: A way to store data in a secondary storage device using Text representation (e.g., ASCII characters)
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.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
Ms N Nashandi Dr SH Nggada 2016/01/03Ms N Nashandi and Dr SH Nggada1 Week 6 -File input and output in C++
Streams and IO  Streams are pipe like constructors used for providing IO.  When a programmer needs to handle input from or output to external entities,then.
Programming II I/O Streams and Data Files 1(c) Asma AlOsaimi.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Introduction Every program takes some data as input and generate processed data as out put . It is important to know how to provide the input data and.
CS212: Object Oriented Analysis and Design
Chapter 15 - C++ As A "Better C"
Today Variable declaration Mathematical Operators Input and Output Lab
Programming with ANSI C ++
Introduction to C++ (Extensions to C)
17 File Processing.
Introduction to Computers Computer Generations
Chapter 1.2 Introduction to C++ Programming
C++ INTERVIEW QUESTIONS
Object-Oriented Programming (OOP) Lecture No. 45
What is a File? A file is a collection on information, usually stored on a computer’s disk. Information can be saved to files and then later reused.
C ++ MULTIPLE CHOICE QUESTION
Object-Orientated 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.
CPSC 231 D.H. C++ File Processing
17 File Processing.
Procedural Programming
files Dr. Bhargavi Goswami Department of Computer Science
Topics Input and Output Streams More Detailed Error Testing
C++ Programming Lecture 8 File Processing
File I/O in C++ II.
Presentation transcript:

Sayed Ahmed Just E.T.C Technologies Inc. Just E.T.C. Education Inc.

C++ is based on and an extension to C Knowing similarities and dissimilarities between C and C++ will help to select the right language for your application development

Comments: Header File: #include Namespace: A defined collection of symbols and variable names within an application The main () function: must have in a program Parentheses: A function/code block name is followed by Parentheses () Braces: Boundary of code blocks

Variables: Used to contain values. Think about variables in Mathematics Statements: An instruction to the computer hardware to perform specific action. Statement Terminator: a semicolon Function calls: One function can call another function. It's just a transfer of control from one code block to another code block. However, the control comes back to the caller again.

#include using namespace std; int main() { int studentId; count << "what is your student ID" << endl; cin>> studentId; count << "Student Id " << studentId << endl; }

A C++ program must have a namespace; C program ends with.c where C++ program ends with.cpp Information communication to and from c program is treated as stream. cout and cin are used for the purpose cout and cin are practically objects

To store values case sensitive must start with letter Supportted datatypes: char, int, float, double, boolean, wchar_t float: usually 32 bits - 6 digit after decimam, double: 64 bits - 10 digit after decimal,

Can be declared anywhere Local: inside functions Static: Inside functions but do not get destroyed after Global: Declared outside the functions can be accessed from anywhere in the program Formal/Parameter Hidden variable: if a local variable use the same name of a global variable the local variable = hidden variable use scope operator :: to access the global variable inside that function

Group of variable A group of variables of the same type in c strings are null terminated arrays C++ also supports a predefined string class/data type; include

in c, define XYZ 100 in c++, const int val=1000

Enables Code Resuse Enables Data Security from Unauthorized Access Object: Attribute + behaviors Primary OOP Concepts Encapsulation: Inheritance: - reduce development time - reuse -increase maintainability of the code Polymorphism: assign different uses to an entity based onthe context Abstraction: simple representation of an objet. hide not essential attributes and behaviors

Object Oriented Paradigm: Define objects - toughest define messages define properties --define attributes --define behaviors Object behavior analysis: Understand the application Derive Objects Categorize Objects Model process flow

C++ Compliers Must Support: ANSI Standard Internationalization Template Locales Namespaces

Friend Class Friend functions and inline functions provide faster, and efficient application A function can be friend to any number of functions Use function declaration to declare friend functions Static Data Members and Static Members Function - create the common members of classes (across objects)

Constructor no return types called at object creation Destructor no return type

Operator Overloading Compile time polymorphism runtime poly - inheritance virtual functions Operator Overloading: -unary -binary -arithmetic -assignment Note: C++ does not support overloading based on return type

Early Binding/Late Binding Access Modifiers absent = protected

inheritance and destructors Diamond Problem: Virtual Base Class Overriding Pure Virtual Function

manipulators COUT, setw, right, setfill, flush, endl fstreambase fstream ifstream ofstream

Mode of file opening ios::in ios::out Sscanf Read formatted file data ifstream fin.getLine() Random File Reading seekg seekp

I/O System Buffered file system Stream classes stream istream--_IO_istream_withassign ostream Iostream Cin is an instance of _IO_istream_withassign Instance of _IO_ostream_withassign cout cerr

Stream formatting flags Can be used with setf(), unsetf() ios::left ios::dec ios::fixed ios::oct ios::right ios::scientific ios::showbase ios::showpoint ios::showpos ios::uppercase

Unformatted input/output character character array strings use text buffer Can provide abstraction of the I/O device functions for unformatted input and output cin.read() cin.gcount() cout.write()

Files fstreambase opening, manipulating, closing fstream, ifstream, ofstream mode ios::app, ios::ate, ios::binary, ios::in, ios::out, ios::trunc fin.getline() Get pointers Random Operation Put pointers pointers Seekg() Seekp() Tellg() Tellp()

Handling Exceptions runtime errors Exceptions try and catch block throw statement Uncaught Exceptions Multiple Catch identified by operating systems if not handled passed to op system exception as int, char,class strings how it passes through functions Derived Class Exceptions catch block hierarchy place derived classes catch up

runtime with virtual functions shape -draw rect tri define overriding by placing function in each Show why virtual function needed? virtual base pointer runtime polymorphism pure virtual function Late binding base point to base - call derive function - runtime-dynamic

Templates create reusable code STL provides some foundational items --templatized functions and --classes These can be used to solve a variety of problems Some STL Elements Containers Algorithms Iterators STLs are compatible across operating systems

Containers Vectors Lists Maps Containers Sequence Associative

Algorithms function templates work with container templates of any type algorithm header file Iterators are objects to cycle through the containers iterator header file needs to be included if iterators are used Iterator type: Random Access Bidirectional Forward Input Output

Vector and Array Comparison container - behave the same way - infinite

Lists: class Bidirectional linear sequentially Functions begin() end() erase() insert(); (template) push_back(); push_front(); remove(); splice();

Associative Container Map templates take two parameters Functions: begin(); clear(); count(); empty(); end(); erase(); insert(); size()

Working with Templates Imagine a situation - complex + many data type Overload may help but time consuming template can help object creation define data type template overloading