In myfunction.h, I declare the function myFunction() inside the namespace MyNamespace:
namespace MyNamespace{
void myFunction();
}
In myfunction.cpp, I include the implementation:
#include "myfunction.h"
void MyNamespace::myFunction(){
std::cout<<"My function"<<std::end;
}
Everything compiles fine.
If instead in the .cpp, I write:
using namespace MyNamespace;
void myFunction(){
std::cout<<"My function"<<std::end;
}
I get an "Undefined Symbol" error during linking. Why?
If instead of a function, I declare a class in the header file, and the implementation of a method of that class in the .cpp file, I have no issue.
MyNamespace::myFunction()No return type. You sure this file's getting compiled?voidI can't reproduce. Mind you, I wouldn't have been able to reproduce without the missingvoid. I'd get completely different errors.using namespace whatever, the functions you define won't actually get added to that namespace still)