David Harmon wrote:
On Tue, 12 Sep 2006 10:13:43 +0200 in comp.lang.c++, Carlos Martinez
<cmg250@nospam.tid.es> wrote,
using namespace ip;
bool esServicioIP() {
...
}
That function is not "inside" the ip namespace. It is a new
definition of its own independent function.
Excuse me. I have ommited code in .h because I have considered obvious.
In .h
namespace ip {
bool esServicioIP();
}
In many other pieces of code with clases instead of functions inside a
namespace, I don't need to qualify class' methods with namespace:
bool MyClass::myMethod() {
...
}
In .h
namespace ip {
class MyClass {
bool myMethod();
}
}
That function must be a member of some namespace or class known as
MyClass that already exists. It's not a valid declaration of
MyClass. Furthermore, MyClass::myMethod must have already been
declared inside the namespace or class.
Is there any rule (perhaps of naming resolution or something else)
different for classes and normal functions?
Not really. For example,
using namespace ip;
MyClass foo; // has no connection with any ip::foo
class bar; // has no connection with any ip::bar
.