headers of the functions in ."cc" file

headers of the functions in ."cc" file

by Faruk Kerem Cekmeceli -
Number of replies: 1

Hello,

  Are we supposed to put headers of all functions in ".cc" file to the ".h" file or just the functions that are necessary for the user of the module are enough ? 

Thank you !

In reply to Faruk Kerem Cekmeceli

Re: headers of the functions in ."cc" file / put only the minimum necessary

by Ronan Boulic -

A la question "que doit-on mettre dans l'interface d'un module ?" le cours a répondu "le moins possible".

1) In a module interface .h put only the prototypes of functions that are needed in other modules. Normally it should be a quite small number because you are supposed to work with classes and methods but it can happen that you need to export some functions too.

2) So all the functions that are only needed locally within the module should be declared as static functions at the beginning of the implementation of that module .cc. It makes them belong to the unnamed namespace of the module. They are invisible for other modules. They must not be visible in the interface of the module.

3) In case you declared static methods within a class, say XYZ, they will be visible outside of the module with the class declaration inside xyz.h. They can even can be used in another module provided you specify where it comes from with the scope operator XYZ::mystaticmethod().