[cs13001] namespaces in header files

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Apr 22 19:07:59 EDT 2013


CSI students,

This afternoon there was a question whether is is advisable to put
namespace definition in header files. The advice is: it is a good idea
if namespace function definitions are in the corresponding source
file.

For example:

// this goes into header file
namespace myNamespace{
  const int limit=5;
  void myFunc(int);  // note the function is just protyped, not defined
}


// this function definition 
// goes into corresponding source file
void myNamespace::myFunc(int a){
  a++;
}



Thanks,
-- 
Mikhail


More information about the cs13001 mailing list