There are some cases when we include .cpp file instead of standard header file (.h), for example:
#include "example.cpp"
instead of
#include "example.h"
It seems to work but is this safe or should I avoid it?
What about the compilation time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s lazy coding. Use header files. Yes they can increase compile time but they mean that you can easily re-implement chunks of your code, or better yet, another developer could at anytime. The header file serves as a template for what your
C/C++code is going to do. It’s a bad idea to discard or ignore it.