.hpp and .cpp

I'm not completely sure but I think .hpp is where we use declare the the class and his member function and datas and in .cpp is where we define thoses member functions...my question is the nextif I declare a .cpp as .hpp something will happen??, could It work in the same way??

Try to be more clear on what your issue or concern is.
If I had any program where I fiend some .cpps and some .hpps what would happen if I changed all .cpps to .hpp less the main.cpp( It would keep that one with his original extension...??
just I want to know if the behaviour would change...
If you change a .cpp file to .hpp, the file would not be compiled.
IDEs only compile .cpp files.


ok, but in fact it's not important what each file contains......as long as the main declares at the begining each .hpp it will work, wont it??.or the main delcare a few .hpp and those one declared in the main declare the rest that complete the whole program. I hope It's understandable...



IDEs only compile .cpp files.
It would compile anything if you would be persistent enough.

Header files (those with extension .hpp) are not compiled. At all. All what they are good for is to copy-passte into actual implementation files. #include is a glorified copy-paste. THere is nothing magic in it. YOu can include anything: .hpp, .cpp, .txt, .exe... And its content would just be pasted inside your file which does inclusion.
Last edited on
I think I do...:), what I mean is, all the .cpp dont have to be declare in the main, if It's the just single one .cpp that I have...while the rest of the .hpp all declare in the ones are already declared in the main( always declaring in each .hpp what is nedded)
ok, clear...but then why is the reason we usually declare member functions in.hpp and define them in .cpp, It's just a convention, isnt it?
You're going down the wrong path. You don't want to do things that way.

.hpp and .cpp files have distinct purposes. .hpp files contain declarations, while .cpp files contain implementation of what is declared in the .hpp file. You don't want to put implementations in a .hpp file. Doing so can cause problems including multiply defined symbols or functions.
ok, thank you both, I have got it clearly...
Topic archived. No new replies allowed.