Consider having the following header file (c++): myclass.hpp
#ifndef MYCLASSHPP_
#define MYCLASSHPP_
namespace A {
namespace B {
namespace C {
class myclass { /* Something */ };
myclass& operator+(const myclass& mc, int i);
}}}
#endif
Consider the implemenation file: myclass.cpp
#include "myclass.hpp"
using namespace A::B::C;
myclass& operator+(const myclass& mc, int i) {
/* Doing something */
}
Consider main file: main.cpp
#include "myclass.hpp"
int main() {
A::B::C::myclass el = A::B::C::myclass();
el + 1;
}
Well, the linker tells me that there is an undefined reference to A::B::C::operator+(A::B::C::myclass const&, int)
What's the problem here?