SlideShare a Scribd company logo
Azerbaijan State Oil and Industry University
Computer Science
Subject: Fundamentals of Programming
Student: Rasulzade Shams
Group: 606.20E
Introduction to C++
Standard Library.
Class Template vector.
C++ Programming Language
C++ is a general-purpose programming language created by Bjarne
Stroustrup in Bell Labs as an extension of the C programming
language, or "C with Classes". The language has expanded
significantly over time, and modern C++ now has object-oriented,
generic, and functional features in addition to facilities for low-level
memory manipulation. It is almost always implemented as a
compiled language, and many vendors provide C++ compilers,
including the Free Software Foundation, Microsoft, Intel, Oracle,
and IBM, so it is available on many platforms.
C++ has also been found useful in many other contexts,
with key strengths being software infrastructure and
resource-constrained applications, including desktop
applications, video games, servers (web search, or SQL
servers), and performance-critical applications (telephone
switches or space probes).
C++ Programming Language
The C++ language has two main components: a direct mapping
of hardware features provided primarily by the C subset, and
zero-overhead abstractions based on those mappings.
Stroustrup describes C++ as "a light-weight abstraction
programming language designed for building and using
efficient and elegant abstractions"; and "offering both
hardware access and abstraction is the basis of C++.
Doing it efficiently is what distinguishes it from other
languages."
C++ Programming Language
#include <iostream>
using namespace std;
int main()
{
cout<< "Hello, world!n";
return 0;
}
C++ inherits most of C's syntax.
Hello world program that uses the C++ Standard Library to write a message to standard output:
The C++ standard consists of two parts: the core language and the standard
library.
C++ programmers expect the latter on every major implementation of C++; it
includes aggregate types (vectors, lists, maps, sets, queues, stacks, arrays, ),
algorithms (find, for_each, binary_search, random_shuffle, etc.), input/output
facilities (iostream, for reading from and writing to the console and files),
filesystem library, localization support, smart pointers for automatic memory
management, regular expression support, time utilities (measurement, getting
current time, etc.), a random number generator and a slightly modified version
of the C standard library (to make it comply with the C++ type system).
C++ Standard Library
A large part of the C++ library is based on the Standard Template Library
(STL). Useful tools provided by the STL include containers as the collections
of objects (such as vectors and lists), iterators that provide array-like access to
containers, and algorithms that perform operations such as searching and
sorting.
As in C, the features of the library are accessed by using the #include directive
to include a standard header.
The C++ Standard Library provides 105 standard headers, of which 27 are
deprecated.
C++ Standard Library
Class Template vector
Templates are the mechanism by which C++ implements
the generic concept. Simply, they allow you to pass data type as
a parameter so that you don’t need to write the same code for different
data types.
Sometimes, you need a class implementation that is same for all classes,
only the data types used are different.
Normally, you would need to create a different class for each data type
OR create different member variables and functions within a single
class.This will unnecessarily bloat your code base and will be hard to
maintain, as a change is one class/function should be performed on all
classes/functions.
However, class templates make it easy to reuse the same code for all
data types.
The C++ Standard Library contains many class templates, in particular
the containers adapted from the Standard Template Library, such
as vector.
The elements of a vector are stored contiguously. Like all dynamic
array implementations, vectors have low memory usage. Unlike other
STL containers, such as lists, vectors allow the user to denote an initial
capacity for the container.
Vectors allow random access; that is, an element of a vector may be
referenced in the same manner as elements of arrays (by array indices).
A typical vector implementation consists, internally, of a pointer to a
dynamically allocated array, and possibly data members holding the
capacity and size of the vector. The size of the vector refers to the
actual number of elements, while the capacity refers to the size of the
internal array.
Class Template vector
The template class that has defined
above serves to store elements of any
valid type.
So as seen, if we wanted to declare an object of
this class to store integer values of type int we
would write:
This same class would also be used to create an
object to store any other type:
Uses of Class Templates
• Remove code duplication
• Generic callback
• Re-use source code as opposed to inheritance and composition, which provides a way to reuse object code
Resources
• https://en.wikipedia.org/wiki/C%2B%2B#Standard_library
• https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library
• https://www.geeksforgeeks.org/templates-cpp/
• https://www.cplusplus.com/reference/vector/vector/
THANK YOU FOR ATTENTION

More Related Content

DOC
Assignment of c++ programming language 2016.doc
PPTX
C++ language
PDF
An Introduction to the C++ Standard Library
PPT
2CPP16 - STL
PPT
UsingCPP_for_Artist.ppt
PPT
lecture5-cpp.pptintroduccionaC++basicoye
PPT
Introduction to Inheritance in C plus plus
PPT
lecture02-cpp.ppt
Assignment of c++ programming language 2016.doc
C++ language
An Introduction to the C++ Standard Library
2CPP16 - STL
UsingCPP_for_Artist.ppt
lecture5-cpp.pptintroduccionaC++basicoye
Introduction to Inheritance in C plus plus
lecture02-cpp.ppt

Similar to Introduction to C++, Standard Library, Class Template vector.pptx (20)

PPT
lecture02-cpp.ppt
PPT
lecture02-cpp.ppt
PPT
lecture02-cpp.ppt
PDF
Programming c++
PDF
C++primer
PDF
Getting Started with C++
PDF
Getting started with C++
PPTX
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
PPT
c++ ppt.ppt
PDF
Programmingwithc 131017034813-phpapp01
PPT
lecture02-cpp.ppt
PPT
C++ - A powerful and system level language
PDF
C++14 - Modern Programming for Demanding Times
PDF
Cpp tutorial
PPTX
Learn c++ Programming Language
PPTX
Return of c++
PPTX
C++ Introduction brown bag
PPTX
Interoduction to c++
lecture02-cpp.ppt
lecture02-cpp.ppt
lecture02-cpp.ppt
Programming c++
C++primer
Getting Started with C++
Getting started with C++
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
c++ ppt.ppt
Programmingwithc 131017034813-phpapp01
lecture02-cpp.ppt
C++ - A powerful and system level language
C++14 - Modern Programming for Demanding Times
Cpp tutorial
Learn c++ Programming Language
Return of c++
C++ Introduction brown bag
Interoduction to c++
Ad

More from emsResulzade1 (6)

PPTX
Digital Coding of Images.pptx
PPTX
Computer Networks Slide.pptx
PPT
Musical Instruments.ppt
PPTX
How to Detect a Lie.pptx
PPTX
The MS-DOS File System.pptx
PPTX
Synchronizing Concurrent Operations in C++.pptx
Digital Coding of Images.pptx
Computer Networks Slide.pptx
Musical Instruments.ppt
How to Detect a Lie.pptx
The MS-DOS File System.pptx
Synchronizing Concurrent Operations in C++.pptx
Ad

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
August Patch Tuesday
PPTX
1. Introduction to Computer Programming.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
A Presentation on Touch Screen Technology
PPTX
TLE Review Electricity (Electricity).pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Encapsulation theory and applications.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Approach and Philosophy of On baking technology
A comparative study of natural language inference in Swahili using monolingua...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Hindi spoken digit analysis for native and non-native speakers
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
August Patch Tuesday
1. Introduction to Computer Programming.pptx
DP Operators-handbook-extract for the Mautical Institute
A Presentation on Touch Screen Technology
TLE Review Electricity (Electricity).pptx
A novel scalable deep ensemble learning framework for big data classification...
OMC Textile Division Presentation 2021.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
cloud_computing_Infrastucture_as_cloud_p
Encapsulation theory and applications.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...

Introduction to C++, Standard Library, Class Template vector.pptx

  • 1. Azerbaijan State Oil and Industry University Computer Science Subject: Fundamentals of Programming Student: Rasulzade Shams Group: 606.20E
  • 2. Introduction to C++ Standard Library. Class Template vector.
  • 3. C++ Programming Language C++ is a general-purpose programming language created by Bjarne Stroustrup in Bell Labs as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.
  • 4. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (web search, or SQL servers), and performance-critical applications (telephone switches or space probes). C++ Programming Language
  • 5. The C++ language has two main components: a direct mapping of hardware features provided primarily by the C subset, and zero-overhead abstractions based on those mappings. Stroustrup describes C++ as "a light-weight abstraction programming language designed for building and using efficient and elegant abstractions"; and "offering both hardware access and abstraction is the basis of C++. Doing it efficiently is what distinguishes it from other languages." C++ Programming Language
  • 6. #include <iostream> using namespace std; int main() { cout<< "Hello, world!n"; return 0; } C++ inherits most of C's syntax. Hello world program that uses the C++ Standard Library to write a message to standard output:
  • 7. The C++ standard consists of two parts: the core language and the standard library. C++ programmers expect the latter on every major implementation of C++; it includes aggregate types (vectors, lists, maps, sets, queues, stacks, arrays, ), algorithms (find, for_each, binary_search, random_shuffle, etc.), input/output facilities (iostream, for reading from and writing to the console and files), filesystem library, localization support, smart pointers for automatic memory management, regular expression support, time utilities (measurement, getting current time, etc.), a random number generator and a slightly modified version of the C standard library (to make it comply with the C++ type system). C++ Standard Library
  • 8. A large part of the C++ library is based on the Standard Template Library (STL). Useful tools provided by the STL include containers as the collections of objects (such as vectors and lists), iterators that provide array-like access to containers, and algorithms that perform operations such as searching and sorting. As in C, the features of the library are accessed by using the #include directive to include a standard header. The C++ Standard Library provides 105 standard headers, of which 27 are deprecated. C++ Standard Library
  • 9. Class Template vector Templates are the mechanism by which C++ implements the generic concept. Simply, they allow you to pass data type as a parameter so that you don’t need to write the same code for different data types. Sometimes, you need a class implementation that is same for all classes, only the data types used are different. Normally, you would need to create a different class for each data type OR create different member variables and functions within a single class.This will unnecessarily bloat your code base and will be hard to maintain, as a change is one class/function should be performed on all classes/functions. However, class templates make it easy to reuse the same code for all data types.
  • 10. The C++ Standard Library contains many class templates, in particular the containers adapted from the Standard Template Library, such as vector. The elements of a vector are stored contiguously. Like all dynamic array implementations, vectors have low memory usage. Unlike other STL containers, such as lists, vectors allow the user to denote an initial capacity for the container. Vectors allow random access; that is, an element of a vector may be referenced in the same manner as elements of arrays (by array indices). A typical vector implementation consists, internally, of a pointer to a dynamically allocated array, and possibly data members holding the capacity and size of the vector. The size of the vector refers to the actual number of elements, while the capacity refers to the size of the internal array. Class Template vector
  • 11. The template class that has defined above serves to store elements of any valid type. So as seen, if we wanted to declare an object of this class to store integer values of type int we would write: This same class would also be used to create an object to store any other type: Uses of Class Templates • Remove code duplication • Generic callback • Re-use source code as opposed to inheritance and composition, which provides a way to reuse object code
  • 12. Resources • https://en.wikipedia.org/wiki/C%2B%2B#Standard_library • https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library • https://www.geeksforgeeks.org/templates-cpp/ • https://www.cplusplus.com/reference/vector/vector/
  • 13. THANK YOU FOR ATTENTION