What is the use of #include in C++?

#include is a preprocessor command. Before the compiler runs, the preprocessor copies the content of the header file into your file. <iostream> declares std::cout, std::cin, std::cerr and std::endl.

#include <iostream>

int main() {
    std::cout << "Hello\n";          // output
    std::cerr << "Error stream\n";   // output for errors
}
Output

Hello
Error stream

< > is used for standard headers, and quotes "my.h" for your own files. See C++ Input and Output.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.