Time for a Namespace Lesson!!!Are namespace low level language shenanigans? As I never heard of them :x
Not really,
a namespace is kind of like a struct or a class,
Syntax is:
namespace namespace_name
{
//Namespace members would go here
void examplefunction()
{
//examplefunction stuff.
}
}
to access a member of a namespace, you use the scope resolution operator "::"
so to call the example function it would be
namespace_name::examplefunction();
They are used for libraries and stuff because it lets them use function names, that other libraries might be using, so to use a function from it you have to include the namespace name. In the standard library there is a namespace called "std"
members of that namespace include things like cout and cin, which are commonly used.
so, in order to use cout or cin, you'd normally have to write it like this.
std::cout or std::cin
if your program uses a lot of functions from one namespace, it might be a better idea to access it using a "using namespace" line,
so if towards the beginning of your code, you write "using namespace std;"
you can access cin and cout without using the namespace name, so in this case it would be
cout or cin
"Hey! that looks both easy AND fun! why don't we do the using namespace thing for ALL the namespaces?!"
woah! calm down there cowboy, yes that may look like a good idea at first, but it includes ALL of the function names from that namespace, so what if you wanted to use 2 namespaces that both had a function with the same name? It wouldn't know what to do with itself, and probably wouldn't do what you want it to.