C/C++ : Why do we need to include the .h while everything works when including only the .cpp file?
Posted
by
reaffer
on Programmers
See other posts from Programmers
or by reaffer
Published on 2014-08-23T16:47:01Z
Indexed on
2014/08/23
22:33 UTC
Read the original article
Hit count: 194
Hi ,
Why do we need to include both the .h
and .cpp
files , while we can make it works with making just a .cpp
file and then including it .
Case one :
Creating a file.h
containing declarations .
Creating a file.cpp
containing definitions .
Including both on the main.cpp
.
Case two :
Creating a file.cpp
containing declaration/definitions ( no prototypes )
Including it on the main.cpp
.
Both worked for me , but still can't the difference since i do not have a background on the compiling and linking process .
© Programmers or respective owner