What happens if I include iostream or any other header file twice in my file? I know the compiler does not throw error.
iostream
Will the code gets added twice
It simply gets skipped over, due to preprocessor code along the following lines:
#ifndef MY_HEADER_H #define MY_HEADER_H #endif
So if you include twice, then MY_HEADER_H is already defined and everything between the #ifndef and #endif is skipped by the preprocessor.
MY_HEADER_H
#ifndef
#endif