Specific programming tip
Programming tips
Search
Add programming tip
Post:
The 18. post
Title:
C++ Avoid Including Multiple Libraries
Language:
C++
Description:
Generally, we include libraries at the start of the C++ code to perform certain operations as shown below. But, we have a better approach to replace these many libraries with just one library i.e, #include bits/stdc++.h> to include all standard libraries without adding them one at a time. It is especially useful in programming competitions where time is limited. This includes all the standard libraries required in the program. So, we can avoid adding these many libraries separately to keep code as efficient and effective as possible.
Code Example:
Generally, we include libraries at the start of the C++ code to perform certain operations as shown below. #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int main() { cout << "GFG!"; return 0; } This “iostream” library performs the input-output operations in C++ code. #include <iostream> The “vector” library allows us to perform operations on vectors. #include<set> This includes all the standard libraries required in the program. So, we can avoid adding these many libraries separately to keep code as efficient and effective as possible. #include<bits/stdc++.h>