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

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

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2
Sisir Ghosh
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
YashpalYadav46
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
 
C, C++ Training Institute in Chennai , Adyar
C, C++ Training Institute in Chennai , AdyarC, C++ Training Institute in Chennai , Adyar
C, C++ Training Institute in Chennai , Adyar
sasikalaD3
 
c++ Unit III - PPT.pptx
c++ Unit III - PPT.pptxc++ Unit III - PPT.pptx
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
prashant patel
 
Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)
Hemant Jain
 
Learn c sharp at amc square learning
Learn c sharp at amc square learningLearn c sharp at amc square learning
Learn c sharp at amc square learning
ASIT Education
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
abdulhaq467432
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
Wei Sun
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++Templates
Ganesh Samarthyam
 
Modern C++
Modern C++Modern C++
Modern C++
Richard Thomson
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
vinu28455
 
Whats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ DevelopersWhats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ Developers
Rainer Stropek
 
Collectn framework copy
Collectn framework   copyCollectn framework   copy
Collectn framework copy
charan kumar
 
Collectn framework
Collectn frameworkCollectn framework
Collectn framework
charan kumar
 
C++ ppt
C++ pptC++ ppt
C++ ppt.pptx
C++ ppt.pptxC++ ppt.pptx
C++ ppt.pptx
Gauravghildiyal6
 

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

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
C, C++ Training Institute in Chennai , Adyar
C, C++ Training Institute in Chennai , AdyarC, C++ Training Institute in Chennai , Adyar
C, C++ Training Institute in Chennai , Adyar
 
c++ Unit III - PPT.pptx
c++ Unit III - PPT.pptxc++ Unit III - PPT.pptx
c++ Unit III - PPT.pptx
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)
 
Learn c sharp at amc square learning
Learn c sharp at amc square learningLearn c sharp at amc square learning
Learn c sharp at amc square learning
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++Templates
 
Modern C++
Modern C++Modern C++
Modern C++
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
 
Whats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ DevelopersWhats New in Visual Studio 2012 for C++ Developers
Whats New in Visual Studio 2012 for C++ Developers
 
Collectn framework copy
Collectn framework   copyCollectn framework   copy
Collectn framework copy
 
Collectn framework
Collectn frameworkCollectn framework
Collectn framework
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
C++ ppt.pptx
C++ ppt.pptxC++ ppt.pptx
C++ ppt.pptx
 

More from emsResulzade1

Digital Coding of Images.pptx
Digital Coding of Images.pptxDigital Coding of Images.pptx
Digital Coding of Images.pptx
emsResulzade1
 
Computer Networks Slide.pptx
Computer Networks Slide.pptxComputer Networks Slide.pptx
Computer Networks Slide.pptx
emsResulzade1
 
Musical Instruments.ppt
Musical Instruments.pptMusical Instruments.ppt
Musical Instruments.ppt
emsResulzade1
 
How to Detect a Lie.pptx
How to Detect a Lie.pptxHow to Detect a Lie.pptx
How to Detect a Lie.pptx
emsResulzade1
 
The MS-DOS File System.pptx
The MS-DOS File System.pptxThe MS-DOS File System.pptx
The MS-DOS File System.pptx
emsResulzade1
 
Synchronizing Concurrent Operations in C++.pptx
Synchronizing Concurrent Operations in C++.pptxSynchronizing Concurrent Operations in C++.pptx
Synchronizing Concurrent Operations in C++.pptx
emsResulzade1
 

More from emsResulzade1 (6)

Digital Coding of Images.pptx
Digital Coding of Images.pptxDigital Coding of Images.pptx
Digital Coding of Images.pptx
 
Computer Networks Slide.pptx
Computer Networks Slide.pptxComputer Networks Slide.pptx
Computer Networks Slide.pptx
 
Musical Instruments.ppt
Musical Instruments.pptMusical Instruments.ppt
Musical Instruments.ppt
 
How to Detect a Lie.pptx
How to Detect a Lie.pptxHow to Detect a Lie.pptx
How to Detect a Lie.pptx
 
The MS-DOS File System.pptx
The MS-DOS File System.pptxThe MS-DOS File System.pptx
The MS-DOS File System.pptx
 
Synchronizing Concurrent Operations in C++.pptx
Synchronizing Concurrent Operations in C++.pptxSynchronizing Concurrent Operations in C++.pptx
Synchronizing Concurrent Operations in C++.pptx
 

Recently uploaded

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 

Recently uploaded (20)

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 

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