I have a very basic question.
Lets take the following code snippet:
#include<iostream>
int main()
{
std::cout<<"Hello world \n";
}
In the above program, does ‘iostream’ gets compiled?
If it compiles, isn’t it a overhead?
Because anyways we are not going to change anything in iostream, but it gets compiled everytime :-/
Please help me understand this.
The include basically pastes the content of
<iostream>in your source file, so you could say it gets compiled.It takes longer, but you need the include because you use
std::cout. This is one of the reasons why you should only include what you need and use declarations instead wherever possible.What you can do is look into precompiled headers.