Question About Header Files
-
- Posts: 4
- Joined: July 3rd, 2012, 11:09 am
Question About Header Files
Why do we need them at all? What's stopping us from taking all of the stuff that's written there and putting it in the .cpp file?
Re: Question About Header Files
Usually the stuff in the header file is needed in more than one .cpp file. For example, D3DGraphics.h is needed in D3DGraphics.cpp and in Game.cpp, Game.h is needed in Game.cpp and Windows.cpp, etc.
Chili
Re: Question About Header Files
Hi DoubleImpact,
When I wrote my last game I put the header and the whole class in the header file. It works quite well, but after watching Chilli's tutorials it makes sense to keep them separate, and then when you include the header file in another class you are only including the header information and not the whole class.
I have read a few C++ books, but not all of them tell you to keep your header files separate, so it can be misleading.
Asimov
When I wrote my last game I put the header and the whole class in the header file. It works quite well, but after watching Chilli's tutorials it makes sense to keep them separate, and then when you include the header file in another class you are only including the header information and not the whole class.
I have read a few C++ books, but not all of them tell you to keep your header files separate, so it can be misleading.
Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk
- npissoawsome
- Posts: 114
- Joined: June 8th, 2012, 3:01 pm
Re: Question About Header Files
Honestly, I think coding C++ without headers would be a mess, full of prototyping and ugh...DoubleImpact wrote:Why do we need them at all? What's stopping us from taking all of the stuff that's written there and putting it in the .cpp file?