Reputation: 169
In the example below, is it necessary to use namespace A{} in the source file or is it redundant as it is already been done in the header file?
// header file Foo.h
namespace A
{
class Foo
{
Foo();
};
}
// source file Foo.cpp
#include "Foo.h"
namespace A
{
Foo::Foo() {}
}
Upvotes: 5
Views: 80
Reputation: 2564
It's necessary, but you can do the following instead:
// source file Foo.cpp
#include "Foo.h"
A::Foo::Foo() {}
Upvotes: 7