Question about namespaces

I had thought that if I used a 'using namespace' that I could define functions in a namespace without having to prepend that namespace. I know that's how it works for classes, but I just realized it doesn't work that way for just functions. Is there a reason why its not the same?

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//main
int main()
{
	int Show = A::Test();
	return 0;
}

//.h
#pragma once

namespace A{
	int Test();
};

//.cpp - this fails to compile and provides linker errors
using namespace A;

int Test(){ return 5; } 
No, using namespace only lets you use symbols in that namespace while skipping the namespace path's root. The symbols still need to be defined within that namespace.
What you can do, however, is this:
1
2
3
namespace A{
    int Test()//...
}
Topic archived. No new replies allowed.