C++ & Standard Template Library: Ganesan C Lead Engineer
C++ & Standard Template Library: Ganesan C Lead Engineer
C++ & Standard Template Library: Ganesan C Lead Engineer
Ganesan C
Lead Engineer
Agenda
2
C & C++
3
C++ Intro
4
Inheritance
5
Mode of Inheritance
6
Encapsulation
7
Polymorphism
8
Classes in C++
Classes are the basic root of OOP Class members are separated by its
in C++ access keywords given below,
Class are nothing but a frame or a Public – members that can be
model of user design to the data accessed both in and out of class via
one of its objects and can be inherited.
processing
Protected– members that can be
Creation of class will not allocate
accessed only inside class via one of
memory to its members but the its objects and can be inherited.
declaration of objects does. Private – members that can be
Classes supports Inheritance of accessed both in and out of class via
members to other classes. one of its objects and can not be
inherited.
Classes can have both variables
By default class members are
and functions as members
Private.
9
Public declaration of Class members
10
Private declaration of Class members
11
Protected declaration of Class members
12
Constructors & Destructors
14
Copy Constructor
15
Polymorphism
16
Templates
17
What is STL?
18
STL That we are going to see…
Container
Sequences
Associative Containers Algorithms
String package Non-mutating algorithms
Rope Mutating algorithms
Container adaptors Sorting
Bitset Generalized numeric algorithms
Iterators Function Objects
Trivial Iterator Adopter
Input Iterator Memory Allocation
Output Iterator Allocators
Forward Iterator raw_storage_iterator
Bidirectional Iterator
Random Access Iterator
19
Container
20
More about Containers
There is no guarantee that the elements of a Container are stored in any definite
order
The lifetime of an element stored in a container cannot exceed that of the Container
itself
The size of a container is the number of elements it contains. The size is a
nonnegative number.
The area of a container is the total number of bytes that it occupies.
A variable sized container is one that provides methods for inserting and/or removing
elements; its size may vary during a container's lifetime. A fixed size container is one
where the size is constant throughout the container's lifetime. In some fixed-size
container types, the size is determined at compile time.
21
Value type X::value_type The type of the object stored in a container. The value type must be Assignable, but need not
be DefaultConstructible.
Iterator type X::iterator The type of iterator used to iterate through a container's elements. The iterator's value type is expected
to be the container's value type. A conversion from the iterator type to the const iterator type must
exist. The iterator type must be an input iterator.
Const iterator type X::const_iterator A type of iterator that may be used to examine, but not to modify, a container's elements.
Reference type X::reference A type that behaves as a reference to the container's value type.
Const reference type X::const_reference A type that behaves as a const reference to the container's value type.
Pointer type X::pointer A type that behaves as a pointer to the container's value type.
Distance type X::difference_type A signed integral type used to represent the distance between two of the container's iterators. This
type must be the same as the iterator's distance type.
Size type X::size_type An unsigned integral type that can represent any nonnegative value of the container's distance type.
22
Valid expressions
23
Forward Container
A Forward Container is
Name Expression Type requirements Return type
a Container whose elements are Equality a == b T is EqualityComparable Convertible
to bool
arranged in a definite order. The Inequality a != b T is EqualityComparable Convertible
to bool
ordering will not change spontaneously Less a<b T is LessThanComparable Convertible
to bool
from iteration to iteration Greater a>b T is LessThanComparable Convertible
to bool
Less or equal a <= b T is LessThanComparable Convertible
Iterators into a Forward Container to bool
Greater or equal a >= b T is LessThanComparable Convertible
satisfy the forward to bool
iterator requirements.
Forward Containers support multi-pass
algorithms and allow multiple iterators
into the same container to be active at
the same time.
24
Iterators
25
Vector [ vector<T, Alloc> ]
26
Deque [ deque<T, Alloc> ]
27
List [ list<T, Alloc>]
28
Container adaptors – stack, Queue
29
Thank you!
http://wf13.myhcl.com/sites/techceed/index.html
30