Ability to use offered C++ codes in appended standard library
Library that provides handling of input / output in programs
Input / output streams (cin , cout, and cerr) and their functionality
Classification of the outcome errors from programs
Important programming skills that you will gain after this
programming course
Standard Library 4
Rich collections of existing code that can be reused in your applications
Common math calculations e.g. sqrt, pow …etc
String / character manipulations
Date / Time functions
Input / output
Error checking
Provided as part of C++ development environment
You can use their capabilities by referring to the corresponding header file that certain library defined in
iostream Library 5
Part of the C++ Standard Library
Provides a uniform way of handling input from and output to predefined sources
Based on the concept of a "stream "
Streams 6
Pre-connected input and output channels between a computer program and its environment when it begins execution
A stream is an object where a program can either insert or extract
characters to or from it
Streams are generally associated to a physical source or destination of characters
a disk file, the keyboard, or the screen
Streams (cont.) 7
Two types
Input streams are used to hold input from a data producer, such as a keyboard, a file
Output streams are used to hold output for a particular data consumer, such as a monitor, a file, or a printer
Programmer only has to learn how to interact with the streams
Details about how the stream interacts with the actual devices is left up to the environment or operating system
Streams (cont.) 8
Standard Input Stream (cin)
Standard Output Stream (cout)
Standard Error Stream (cerr)
keyboard
cin cout
screen
cerr
program
cin and cout 9
Think of cout as a variable that accepts all data bound for standard output
Think of cin as a variable that accepts all data bound for standard input
The cout and cin declarations and definitions are located in the header file “iostream”
All of the Standard C++ libraries are wrapped in a single
namespace std “standard”
Namespaces 10
A mechanism for logically grouping declarations and definitions into a common declarative region
Problem
It becomes harder to think of new names for functions and variables when your programs reach a certain size
C++ has a single arena where all the names live
All developers must be careful not to accidentally use the same names to avoid conflict
Namespaces (cont.) 11
Solution
the namespace keyword
Each set of C++ definitions in a library or program is “wrapped” in a namespace
You can create your own namespace that hold blocks of codes then can be accessed by any code inside or outside the namespace
Common Errors 12
Syntax (compilation) Errors
encountered during compilation
occurs when an instruction does not follow the syntax rules of the
programming language
e.g. forgetting a semicolon
Logic (Semantic) Errors
Not detected during compilation
produces unintended or undesired results
e.g. forgetting to initialize a sum variable
Common Errors (cont.) 13
Runtime (Execution-time) Errors
occurs during the execution of a program
May sometimes cause the program to crash
e.g. division by zero
You must develop 3 skills
Design
Debug
Trace
Introduction and Basics in
Important programming skills that you will gain after this ... Rich collections of existing code that can be reused in your ... a common declarative region.