namespace and header
cpp
- self header file
- use header file
- namespace for convention
- functions
.h
- define
- include header file
- do not use namespace
- function prototype
Reference
- why we distribute h and cpp
.h파일과 .cpp파일을 구분하는 이유가 있나요?
왜 C++에서는 헤더 파일이랑 .cpp파일을 따로 쓰나요?
https://hashcode.co.kr/questions/378/h%ED%8C%8C%EC%9D%BC%EA%B3%BC-cpp%ED%8C%8C%EC%9D%BC%EC%9D%84-%EA%B5%AC%EB%B6%84%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0%EA%B0%80-%EC%9E%88%EB%82%98%EC%9A%94
- do not use using namespace in header file
C++에서 "using namespace std"를 *.h에 안쓰고 *.cpp에 쓰니까 에러가 나네요.
안녕하세요, 약간 이상한 것을 경험해서 왜 그런지 궁금해서 질문을 올립니다. 제가 C++로 class.h와 class.cpp로 파일을 나누어서 작성했습니다. 어디선가 얼핏 보기를 "using namespace std"를 *.cpp에 적는 것이 좋다고 본 기억이 있어서 아무생각없이 *.cpp에 적고 test겸해서 컴파일을 해 보니 도대체 이유를 알 수 없는 에러들이 생기더군요.
https://kldp.org/node/72499

- we do not have to include c++ and prototype and define should be in header
C++ header file convention
Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers.
https://stackoverflow.com/questions/1814772/c-header-file-convention
- using without include is illegal because
"using namespace std;" without any #include?
All using namespace std does is tell the compiler that, when an identifier (named variable, type, etc) appears in code, to look in the std namespace for candidates to match the name. Within your main() function, no identifiers are being used at all (the {} is an empty block).
https://stackoverflow.com/questions/44350579/using-namespace-std-without-any-include


Seonglae Cho