Topic: Q: Defining Namespace Members
Author: John I. Moore, Jr. <70672.1744@CompuServe.COM>
Date: 1995/06/03 Raw View
I have a question about the best (and correct) approach for
defining namespace members. The draft standard says that members
of a namespace can be defined within that namespace. Since
namespaces can be spread over multiple files, it appears to be
possible to declare a member in a header file and define it in a
source code file, similar to the following:
// in file f.h
namespace N { void f(int); }
// in file f.cpp
namespace N { void f(int n) { ... } }
However, several textbooks (Martin, Eckel, ...) seem to imply
that a member of a namespace can be defined at "file level"
using explicit qualification notation as follows:
// in file f.cpp
void N::f(int n) { ... }