C
Carlos Martinez
//general.h
#ifndef _GENERAL_H
#define _GENERAL_H
namespace ip {
bool esServicioIP();
}
#endif //_GENERAL_H
//general.cc
#include <general.h>
....
using namespace ip;
bool esServicioIP() {
....
}
//distsgip.cc
.....
if(esServicioIP()) {
...
}
Code compiles ok, but linker gives me an error saying ip::esServicioIP
is undefined.
Instead if I put namespace ip when defining esServicioIP:
bool ip::esServicioIP() {
....
}
Code compiles and links ok.
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() {
....
}
Compiles and links ok
Is there any rule (perhaps of naming resolution or something else)
different for classes and normal functions?
Thanks in advance
#ifndef _GENERAL_H
#define _GENERAL_H
namespace ip {
bool esServicioIP();
}
#endif //_GENERAL_H
//general.cc
#include <general.h>
....
using namespace ip;
bool esServicioIP() {
....
}
//distsgip.cc
.....
if(esServicioIP()) {
...
}
Code compiles ok, but linker gives me an error saying ip::esServicioIP
is undefined.
Instead if I put namespace ip when defining esServicioIP:
bool ip::esServicioIP() {
....
}
Code compiles and links ok.
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() {
....
}
Compiles and links ok
Is there any rule (perhaps of naming resolution or something else)
different for classes and normal functions?
Thanks in advance