2.10 Header files

주홍영·2022년 3월 11일
0

Learncpp.com

목록 보기
34/199

https://www.learncpp.com/cpp-tutorial/header-files/

이번 섹터에서는 header file에 대해서 이야기 한다

Headers, and their purpose

프로그램이 커지면 각 파일마다 필요한 함수를 forward declaration하고 사용하기에
매우 비효율적이다
Header file은 .h 확장자를 쓰는데 주된 목적은 코드 파일에
declaration을 propagate 하는 것이다

Rule

Use double quotes to include header files that you’ve written or are expected to be found in the current directory. Use angled brackets to include headers that come with your compiler, OS, or third-party libraries you’ve installed elsewhere on your system.

큰따옴표는 현재 파일이 존재하는 폴더에 내가 작성한 헤더파일이 있을 경우,
<>는 compier, os, 설치한 third-party libraries 등을 사용할 때

Why doesn’t iostream have a .h extension?

#include <iostream.h> 와 #include < iostream >은
엄밀히 서로 다른 파일이다
C의 iostrem.h를 계승해서 naming collision을 막기 위해 std namespace를 추가해
만든 것이 그냥 iostrem이다

Including header files from other directories

이러한 경우 path를 명시해서 사용할 수 있다

#include "headers/myHeader.h"
#include "../moreHeaders/myOtherHeader.h"
profile
청룡동거주민

0개의 댓글