- Imagine headerfiles are part of eco.
- To access the func in lib We need headfle.
π² Root:C++ Program[filename.cpp]
|
ββββββββββββββββββββββΌβββββββββββββββββββββ
| | |
π Header Files π§° Lib Files π§ Namespaces
(.h / .hpp) (.lib / .dll / .so) (std, custom)
|
ββββββΌβββββ
| | |
Declarations: Functions, Classes, Constants
- Here Lib files are hidden machine behind leaves.
/* π Header file (declares std::cout) # x ''' - Serpen
π§ Namespace (lets skip std:: prefix) */
#include <iostream>
using namespace std;
int main()
{
cout << "Rehaan's tree is growing strong!" << endl; // We use endl for cout not for cin.
return 0;
} Header files
1.Standard Header files 2.User-Defined Header files
*Built-in x Part of stndrd Lib of C++ *Name defines.
- Initiate header files through
#include<headerfile1>or#include "headerfile" - Without
#includecompiler dont know whatscoutand When it knows it usesiostreamto understand it asstd::cout. #Examples of Header files
| Header File | Purpose | Qi Functions / Classes |
|------------------|--------------------------------------------- |---------------------------------------------------- |
| `<iostream>` | Input/output stream operations | `std::cin`, `std::cout`, `std::cerr`, `std::endl` |
| `<cmath>` | Mathematical computations | `sqrt`, `pow`, `log`, `sin`, `cos`, `ceil`, `floor` |
| `<cstdlib>` | General utilities and memory management | `rand`, `exit`, `malloc`, `free`, `system` |
| `<cstring>` | C-style string manipulation | `strlen`, `strcpy`, `strcmp`, `strcat` |
| `<string>` | C++ string class and operations | `std::string`, `length`, `substr`, `find` |
| `<vector>` | Dynamic array container | `std::vector`, `push_back`, `size`, `begin`, `end` |
| `<map>` | Key-value associative container | `std::map`, `insert`, `find`, `erase` |
| `<set>` | Unique element container | `std::set`, `insert`, `count`, `erase` |
| `<algorithm>` | Common algorithms | `sort`, `reverse`, `max_element`, `find` |
| `<iomanip>` | Output formatting | `setw`, `setprecision`, `fixed`, `showpoint` |
| `<fstream>` | File input/output streams | `std::ifstream`, `std::ofstream`, `std::fstream` |
| `<ctime>` | Time and date utilities | `time`, `clock`, `difftime`, `localtime` |
| `<cassert>` | Runtime assertions | `assert` |
| `<typeinfo>` | Runtime type information | `typeid` |
| `<limits>` | Numeric limits of data types | `std::numeric_limits<T>::max()` |
- Concept of dividing the programs into modules.
DS
|
-------------------
| |
Primtve DS Non-Prmtve S
| |
Int Lnr NLnr
char | |
float Arr Tress
double Que Graph
Stck
Likdlst
#include<iostream> //char x String Capital small And Number
using namespace std;
#include<string>
int main()
{
int n,A[n];
char B[n],D;
string C[n],E;
n = 1; // string has more functions compared to char!.
D = '1';
string E ='2';
}createdeleteupdateProcess