I am wondering how compiler (or preprocessor) include headers. I have three files. First is header.h, second first.cpp <- and there is #include <iostream>, third <- it contains #include <iostream> too.
header.h:
#ifndef HEADER_H_
#define HEADER_H_
struct Student
{
std::string imie;
int ocena;
};
void foo();
#endif
first.cpp:
#include <iostream>
#include "header.h"
int main()
{
Student Jan;
std::cout << "It's OK" << std::endl;
foo();
return 0;
}
Second.cpp:
#include <iostream>
#include "header.h"
void foo()
{
std::cout << "I like Linux" << std::endl;
}
And my question is do the compiler copy code from library twice? Should I cut all iostream from .cpp's to one .h?