Reputation: 25592
Consider I have the following function prototype:
void MyFunction(int MyParameter);
With the following definition:
void MyFunction(int MyParameter)
{
// Do stuff here.
}
Where should they each be put if I have a header file (no main
function) with a namespace? Does the prototype go in the namespace and the definition outside it? Or do they both go in?
Upvotes: 0
Views: 4414
Reputation: 6488
If you choose to have a namespace, both should be inside :
.h :
namespace MyNameSpace {
void MyFunction(int MyParameter);
}
.cpp :
void MyNameSpace::MyFunction(int MyParameter)
{
// Do stuff here.
}
Upvotes: 2
Reputation: 80001
If your prototype is not in the namespace, then you do not have to put the definition in the namespace. If the prototype is in a namespace, the definition should be in the same namespace.
Upvotes: 1