American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 04
Functions in C+
Functions in C+
void swap(int &a, int &b)cfw_
int temp;
temp=a;
a=b;
b=temp;
int main()cfw_
int a=10,b=5;
cout<a<" : "<b<endl;
swap(a,b);
cout<a<" : "<b<endl;
return 0;
Type Cast Operator
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
Graphs: Chapter 9
1
What is a Graph?
Definition1: A graph G = (V,E) consists of V, a
nonempty set of vertices (or nodes) and E, a set of
edges.
Each edge has either one or two vertices associated
with it, called its end p
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
9.4 Connectivity
9.5 Euler and Hamilton Paths
1
Paths
A path is a sequence of edges that begins at a
vertex of a graph and travels from vertex to
vertex along edges of the graph.
2
Paths
Definition1: Let n be a nonnegativ
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
3.4 The Integers and Division
3.5 Primes and Greatest Common Divisors
3.8 Matrices
1
3.4 The Integers and Division
Definition 1: If a and b are integers with a0, we say
that a divides b if there is an integer c such that b
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
Chapter 2
2.1 Sets
1
Sets
Curly brace notation cfw_
Cardinality  
Element containment
Subset containment
Empty set cfw_ =
Power set P(S ) = 2S
Ntuples ( ) and Cartesian product
2
Set
Definition1: A set is a
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
10.1 Introduction to Trees
1
What is a Tree?
Definition: A tree is a connected undirected graph
with no simple circuits.
2
Example 1 (p.683)
Which of the graphs shown in Figure 2 are trees?
3
Example 1 (p.683)
Solution:
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
10.3 Tree Traversal (cont.)
1
Tree Traversal
Tree traversal: A listing of the vertices of a tree.
A traversal operation is to visit each node in the tree,
for example, to perform a task in each node.
Traversal algorithms
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
4.1 Mathematical Induction
1
4.1 Mathematical Induction
Suppose that we have an infinite ladder, and we want
to know whether we can reach every step on this
ladder.
We know two things
1) We can reach the first rung of th
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
10.2 Applications of Trees
10.3 Tree Traversal
1
Common Uses of Trees
Manipulate hierarchical data
Make information easy to search
Manipulate sorted lists of data
As a workflow for compositing digital images for
visual effe
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
5.1 The Basics of Counting
5.2 The Pigeonhole Principle
5.3 Permutations and Combinations
1
5.1 The Basics of Counting
Basic counting principles: We will present two
basic counting principles:
Product rule
Sum rule
2
The
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
2.2 Set Operations
1
Set Operations
Union ( )
Intersection ( )
Disjoint
Difference ( )
Complement(
)
Symmetric Difference ( )
2
Union of Sets
Definition: Let A and B be sets. The union of the sets A and B,
denoted by A U B
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
Chapter 1
1.3 Predicates and Quantifiers
1
Agenda
Predicate Logic
Predicates
Quantifiers
Existential Quantifier,
Universal Quantifier,
2
Predicates
Predicate: A property that the subject of the statement can
have.
Exampl
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
Chapter 1
1.1 Propositional Logic
1
Key Terms
Logic: Logic is the discipline that deals with the
methods of reasoning.
Logic is the basis of all mathematical reasoning
The rules of logic specify the meaning of
mathematic
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 05
Classes & objects
Class & Objects
Class: A class is a way of binding data &
its associated functions together.
Data of a class are called member data.
Functions of a class are called member
function.
A
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With
C+
Chapter 03
C+ as a better C
Start with a program
Modern C+ headers do not
use .h extension
#include<iostream>
using namespace std;
A namespace creates a
int main()
declarative region in which
various program elements
c
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 06
Constructors &
Destructors
Constructors
A constructor is a member function of a class which is
called whenever an object is created.
Name of the constructor function must be same as the
class name.
It has
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With
C+
Chapter 01
Principles of object
oriented programming
Need of OOP
Here is the fate of the US defense software
projects undertaken in the 1970s
50% of the software were never delivered
one third of what delivered was n
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 07
(c) 2005, Adnan Faisal, AIUB
1
Operator overloading
& type conversion
(c) 2005, Adnan Faisal, AIUB
2
Operator Overloading
Operator Overloading means giving extra meaning to
operator so that they can work w
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 11
Working with files
Files
1.
2.
fstream is an interface between program & the
file.
Ifstream extracts instructions from file (>).
ofstream inserts instructions into file (<).
There are 2 formats of file ope
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 09
Pointers, virtual
functions &
polymorphism
Pointer to objects
If B is a base class and D is a derived class from
B, then a pointer declared as a pointer to B
can also be a pointer to D.
B * pb;
B b;
D d;
p
American International University Bangladesh (Campus 4)
programming language c++
CSE 001

Spring 2015
Object Oriented
Programming With C+
+
Chapter 13
Exception handling
Exception
Exceptions are runtime anomalies or an unusual
condition that a program may face.
Exceptions are neither syntax error nor logical error.
In C+ following keywords are used to h
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
Chapter 1
1.2 Propositional Equivalences
Tautology
Tautology: A compound proposition that is always
true is called a tautology.
Examples:
a) p p
b) The professor is either a woman or a man
c) People either like watching T
American International University Bangladesh (Campus 4)
discrete math
CSE 001

Summer 2015
Discrete Mathematics
(CSC 1204)
2.3 Functions
2.4 Sequences and Summations
1
Functions
Definition 1: Let A and B be nonempty sets.
A function f from A to B is an assignment of exactly
one element of B to each element of A.
We write f(a) = b if b is the u