The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
31 views

About Headers and rules about .cpp [duplicate]

I am a beginner with programming and there is concept I'm not understanding about headers files. What I'm told is that headers files are made to separate concept about the actual code and that the ...
0
votes
4answers
294 views

cpp and h/hpp #include: “why” question

Why does the source include a header and not also the other way around? I googled it but only found questions regarding the use of header files, how to include them but nowhere to say why it is like ...
0
votes
1answer
59 views

When should I use a precondition and when to include another use-case to provide those conditions?

For example, suppose 'Borrwoing a book' a use case: I can figure out two description for it: Description one: Precondition: The member to access this use-case should be already logged in. OR EVEN ...
26
votes
7answers
3k views

Is it good practice to rely on headers being included transitively?

I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
5
votes
7answers
4k views

Why do we need to include the .h while everything works when including only the .cpp file?

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 . For example, Creating a file.h containing declarations, then ...
2
votes
0answers
162 views

Single complex or multiple simple autoload functions

Using the spl_autoload_register(), should I use a single autoload function that contains all the logic to determine where the include files are or should I break each include grouping into it's own ...
3
votes
1answer
560 views

When defining directory path, should a trailing slash be included?

Say I'm defining a directory and then including files from it. Is it better practice to do: define('PATH', 'C:/xampp/htdocs/includes/'); require PATH.'header.php; or: define('PATH', ...
5
votes
5answers
735 views

Is it bad to place “include directive” within main function?

It is always said that the include directives should be placed at the beginning of a script. The main reason is to make the functions available throughout the script. Regardless of this fact, is it ...
6
votes
7answers
2k views

Ensuring that headers are explicitly included in CPP file

I think it's generally good practice to #include the header for any types used in a CPP file, regardless of what is already included via the HPP file. So I might #include <string> in both my HPP ...
3
votes
1answer
146 views

Handling bugs, quirks, or annoyances in vendor-supplied headers

If the header file supplied by a vendor of something with whom one's code must interact is deficient in some way, in what cases is it better to: Work around the header's deficiencies in the main ...
2
votes
1answer
512 views

Including local headers first

So I read up on the ordering of your includes, and this guy suggested you include your local header first so as to make sure it doesn't have prerequisites. Ok, I get that. I'm on board. The whole ...