1

Let's say I have a header file dummy.h, and a corresponding dummy.cpp or dummy.c. When I switch from the first to the second, I can say "I switch from the header to its implementation". But how can I express the opposite? "Header's implementation" sounds ok, but "Implementation's header" not really.

The question came to me when I wanted to express the concept that an implementation file should first of all include... its own header. (This is actually not the topic of this question, it might very well be a future question, if I understand how to ask it).

I saw a couple of occurrences of the term "corresponding header", but it's not used so often to be sure it's the right term.

David Ranieri
  • 39,972
  • 7
  • 52
  • 94
Antonio
  • 19,451
  • 13
  • 99
  • 197
  • I call it the 'interface'... I think this might be a technical name – Matthew Aug 03 '16 at 15:21
  • 1
    Why not "I switch from the implementation to the header"? I don't think there's standardised terminology: my office calls them "source" and "header" respectively "Look at dummy's source/Look at dummy's header" – KidneyChris Aug 03 '16 at 15:23
  • 3
    Typically you have your _declarations_ in the header file and _definitions_ in the source file. I think "corresponding header" is clear enough. I often find myself referring to the corresponding header as "the dot h" (as in `.h`)... i.e. if I need to talk about `foo.cpp`'s corresponding header, I might say "foo's dot h file." – Chris Sprague Aug 03 '16 at 15:23
  • 6
    There is no official/technical term. "Corresponding header" is perfectly acceptable. – Rob K Aug 03 '16 at 15:25
  • I think corresponding header is fine. For the .c file the technical term is 'module', because it is what actually gets compiled. The header file is also source code, which gets included in the module to create a translation unit, that gets compiled. The thing with "corresponding header" is that it should include what another module should be able to access. – Eirik M Aug 03 '16 at 15:27
  • The point is that such an association is *conventional* (and not every project follows that convention). For small projects (of less than e.g. 100KLOC) I don't use such a convention. I would have a *single* header file included by all the translation unit (e.g. `*.c`). – Basile Starynkevitch Aug 03 '16 at 15:30
  • Here is Dummy's Class Implementation. – Omid CompSCI Aug 03 '16 at 15:30
  • @RobK I am ok with the question being closed, however when I asked, there was no way to know if a technical term existed, and that this would have generated opinion-based discussion. – Antonio Aug 04 '16 at 12:42

2 Answers2

1

You have a module, consisting of an interface (the header) and an implementation (the C++ file).

So you can say the interface or header of the module, and the implementation or C++ file of the module.

Compare it to the wheels and motor of a car. You can say wheels of a car, motor of a car, but not (in the most obvious sense) wheels of a motor, motor of the wheels.

And: All this is only half true, since language isn't mathematics... So in fact to me all the possibilities you mention do the job: to clarify to me what you mean.

Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
  • C++ does not have modules. – Lightness Races in Orbit Aug 03 '16 at 15:49
  • @LightnessRacesinOrbit In C++, can't it be used as synonymous of [translation unit](http://stackoverflow.com/a/1106167/2436175)? See http://stackoverflow.com/a/14714959/2436175 – Antonio Aug 03 '16 at 18:11
  • I like your answer. However, if "module" is just a synonymous of "translation unit", it sound very strange to say "the interface (or the header) of the translation unit". – Antonio Aug 03 '16 at 18:17
  • @Antonio: That very answer makes it pretty clear that the term should be avoided for its use is at best non-standard and at worst highly ambiguous. – Lightness Races in Orbit Aug 03 '16 at 22:33
0

It appears there is no official/technical term for this. Given the comments, it seems there's an agreement that the term "corresponding header" is clear enough.

To be totally unambiguous, I can express my concept saying:

An implementation file should first of all include the header file it is implementing.

(And then, the concept might be correct or wrong, but this is another story :) )

Antonio
  • 19,451
  • 13
  • 99
  • 197