Note that there are some explanatory texts on larger screens.

plurals
  1. POA basic understanding of C++ header files
    primarykey
    data
    text
    <p>I have a theory question rather than an error report.</p> <p>I'm a rookie C++ programmer, trying to promote that away</p> <p>Using the VC++ VS2008 compiler</p> <p>I am often finding myself wondering WHY I want to take some actions in header files.</p> <p>For example look at this code block:</p> <pre><code>#include "DrawScene.h" #include "Camera.h" #include "Player.h" #include "Grid.h" #include "InputHandler.h" #include "GameState.h" class Controller { public: private: public: Controller(); ~Controller(){} void Update(); private: }; </code></pre> <p>And the hooked up CPP file , controller.cpp along with it</p> <pre><code>#include "stdafx.h" #include "glut.h" #include "Controller.h" #include &lt;iostream&gt; Grid* grid_ptr = new Grid(); InputHandler* inputHandler_ptr = new InputHandler(); DrawScene* drawScene_ptr = new DrawScene(); GameState* gameState_ptr = new GameState(); Controller::Controller() { } void Controller::Update() { } </code></pre> <p>What is a good way to decide which includes go where? So far I've been going with the " whatever works" method but I find it somewhat unprofessional. </p> <p>Now even though you can say my code has X syntax errors and design flaws, please do, but the focal point I would appreciate that information remains on the use of .h VS .cpp files.</p> <p>Why is there even such a design? And what are the pits and traps to always be treading lightly around when making any kind of OOP based C++ program?</p> <p>What sparked this question for me btw was that I wanted to notify the reader of the header file there will be objects stored in the controller but assigning these uninitialized objects seemed impossible without making them static. </p> <p>Note: I stem from C# --> C++ , might help to know. That's kind of my perspective on code at this point.</p> <p>Thank you in advance for you efforts!</p> <p>EDIT: 26/08/2010 18:16</p> <p>So the build time is the essence of good includes. Is there more to be cautious about?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload