Simple question about headers

Hello !

I am reading my book's section on headers and I don't really understand why we need to have two files when needing to call a header in a main function...like class.h and then a cpp file for class. Why can't we just put it all in class.h?? :S
I know this is probably a really silly question but I'm super confused!!

well firstly, you cant have functions in a header, and if you want to define the methods for a class declared in a .hpp file you can do that (which i like since it looks cleaner)
Oh so it's just impossible from the get-go! I see, well alright that make senses then why we use a different file for it....Thank you !
no problem! if you have any more questions dont hesitate to ask
Uhm, I believe you can define functions in a header file. Its just not recommended because if you change the logic you have to recompile every file that relies on that header.
Topic archived. No new replies allowed.