Uses of Header Files in C++

Uses of Header Files in C++
Techiio-author
Written by Sagar RabidasFebruary 2, 2022
12 min read
C++
1 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWS SHARE
Techiio-author
Sagar Rabidas

Software Developer

In this blog, we will discuss the uses of header files in C++

C++ Header Files

Header documents are used in this program which contains the definition or implementation of the predefined capabilities and variables. The header documents can be used on this software with the aid of using the preprocessor directives that are #consist of. All header documents of this will or may not end with the aid of. H extension, while in name header files ought to quit by. H extension.

Syntax

The syntax to include header files:

#include<iostream>

Or

#include"iostream"

Types of Header Files in C++

Types of header files

  1. System header files – These are predefined header files presented in these compilers.
  2. User header files – these are user-defined header file includes in this program by #define directive.

Next, we see the list of system-defined header files category wise below –

  • Input/output library

Code:

<iostream> - This defines standard stream objects.
<ios> - This defines several typedefs and class template of std::ios_base class, std::basic_ios.
<istream> - This defines several typedefs and class template of std::basic_istream.
<ostream> - This defines several typedefs and class template of std::basic_ostream, std::basic_iostream.
<fstream> - This defines several typedefs and class template of std::basic_ifstream, std::basic_fstream, std::basic_ofstream.
<sstream> - This defines several typedefs and class template of std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream.
<iosfwd> - This defines library for input/output forward declarations classes.
<syncstream> - This defines several typedefs and class template of std::basic_osyncstream, std::basic_syncbuf.
<strstream> - This defines std::istrstream, std::strstream, std::ostrstream.
<iomanip> - This defines formatting function of input and output.
<streambuf> - This defines class template of std::basic_streambuf.
<cstdio> - This defines C input/output functions Concepts.
<concepts> - This defines library for fundamental concepts Coroutines.
<coroutine> - This defines library for coroutine support.
  • Strings library

Code:

<cctype> - This defines library for Functions to determine character type.
<cwctype> - This defines library for Functions to determine wide character type.
<string> - This defines library for class template of std::basic_string.
<cstring> - This defines library for string handling functions of narrow character.
<cuchar> - This defines library for C Unicode character conversion functions.
<string_view> - This defines library for class template of std::basic_string_view.
<format> - This defines library for std::format.
<charconv> - This defines library for class template of std::from_chars and std::to_chars
  • Containers library
Code:
<array> - This defines library for container of std::array.
<list> - This defines library for container of std::list.
<vector> - This defines library for container of std::vector.
<set> - This defines library for association container of std::set and std::multiset.
<unordered_set> This defines library for association container of std::unordered_set and std::unordered_multiset.
<deque> - This defines library for container of std::deque.
<forward_list> - This defines library for container of std::forward_list.
<map> - This defines library for association container of std::map and std::multimap.
<unordered_map> - This defines library for unordered association container of std::unordered_map and std::unordered_multimap.
<stack> - This defines library for container adaptor of std::stack.
<span> - This defines library for view of  std::span.
<queue> - This defines library for container adaptor of std::queue and std::priority_queue.
  • Numerics library
Code:
<numbers> - This defines library for Math constants.
<cmath> - This defines library for mathematics functions.
<numeric> - This defines library for Numeric operations.
<complex> - This defines library for Complex number.
<valarray> - This defines library for arrays representing and manipulating of values class.
<random> - This defines library for generators and distributions of random number.
<ratio> - This defines library for Compile time rational arithmetic
<cfenv> - This defines library for functions to access Floating-point environment.
<bit> - This defines library for function for Bit manipulation.
  • Error handling

Code:

<exception> - This defines library for utilities of Exception handling.
<system_error> - This defines library for platform-dependent error code, std::error_code.
<cerrno> - This defines library for error number.
<stdexcept> - This defines library for exception objects.
<cassert> - This defines library for macro(Conditionally compiled) that compares its argument to zero.
  • Utility library

Code:

<utility> - This defines library for utility.
<csignal> - This defines library for signal management.
<cstdlib> - This defines library for general purpose utilities like dynamic memory allocation, program control, sort, random numbers and search.
<csetjmp> - This defines library for an execution context like Macro or function that saves or jumps location.
<typeinfo> - This defines library for runtime type information utilities.
<cstdarg> - This defines library for handling argument lists of variable length.
<typeindex> - This defines library for std::type_index.
<bitset> - This defines library for class template std::bitset.
<type_traits> - This defines library for Compile time type information.
<functional> - This defines library for Function invocations, function objects, Reference wrappers and Bind operations.
<ctime> - This defines library for C time/date utilities.
<chrono> - This defines library for C++ time utilities.
<initializer_list> - This defines library for class template of std::initializer_list.
<cstddef> - This defines library for standard typedefs and macros.
<tuple> - This defines library for class template of std::tuple.
<optional> - This defines library for class template of std::optional.
<any> - This defines library for class template of std::any.
<variant> - This defines library for class template of std::variant.
<source_location> - This defines library for to obtain location of source code.
<compare>- This defines library for comparison operator.
<version> - This defines library for information implementation-dependent library.
  • Numeric limits

Code:

<limits> - This defines library for to query properties of arithmetic types.
<climits> - This defines library for limits of integral.
<cstdint> - This defines library for fixed-size and limits of other data types.
<cfloat> - This defines library for limits of float.
<cinttypes> - This defines library for conversions, formatting macros , intmax_t and uintmax_t math.
  • Dynamic memory management

Code:

<memory> - This defines library for utilities of higher level memory management.
<new> - This defines library for utilities of Low-level memory management.
<memory_resource> - This defines library for resource of Polymorphic allocators and memory.
<scoped_allocator> - This defines library for class of Nested allocator.
  • Iterators library

Code:

<iterator> - This defines library for iterators range.
  • Ranges library

Code:

<ranges> - This defines library for utilities and adaptors of Range access, primitives, requirements.
  • Algorithms library

Code:

<execution> - This defines library for algorithm execution policies for parallel versions.
<algorithm> - This defines library for Algorithms used on ranges.
  • Localization library

Code:

<clocale> - This defines library for utilization of C localization.
<locale> - This defines library for utilities Localization.
<codecvt> - This defines library for facilities of Unicode conversion.
  • Filesystem library

Code:

<filesystem> - This define classes and functions for std::path.
  • Regular Expressions library

Code:

<regex> - This defines library for regular expression classes, algorithms and iterators.
  • Atomic Operations library

Code:

<atomic> - This defines library for Atomic operations.
  • Thread support library

Code:

<stop_token> - This define stop tokens of std::jthread.
<thread> - This defines library for classes and function of std::thread.
<mutex> - This define primitives for mutual exclusion.
<shared_mutex> - This define primitives for shared mutual exclusion.
<semaphore> - This define semaphores.
<future> - This define asynchronous computations primitives.
<latch> - This define latches.
<condition_variable> - This define conditions for thread waiting.
<barrier> - This define barriers.

How and to Why use C++ Header Files?

Next we write the example to see how and to why use header files below –

Code:

#include"iostream"
#include<string>
using namespace std;
int main()
{
string name;
cout <<"Please enter your name : ";
getline(cin,name);
cout<<"Your name is = "<<name;
return 0;
}

C
C++
Header Files in C++
1 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance