K
Kasper Heftholm Kristensen
Hi.
I want to change the used namespace at runtime depending on another
variable, but I'm not sure how to does this, if possible.
The code below will not compile, but I hope it gives you an idea of
what I'm trying to accomplish.
I guess it has to do with how namespaces are only defined withing a
block, but I have know idea how to do it in another way.
Cheers,
Kasper Kristensen
// ---------------------- CODE--------------------------
namespace A
{
int test=1;
}
namespace B
{
int test=2;
}
int main(int argc, char* argv[])
{
bool useA=true;
if(useA)
using namespace A;
else
using namespace B;
cout << test << "\n";
return 0;
}
I want to change the used namespace at runtime depending on another
variable, but I'm not sure how to does this, if possible.
The code below will not compile, but I hope it gives you an idea of
what I'm trying to accomplish.
I guess it has to do with how namespaces are only defined withing a
block, but I have know idea how to do it in another way.
Cheers,
Kasper Kristensen
// ---------------------- CODE--------------------------
namespace A
{
int test=1;
}
namespace B
{
int test=2;
}
int main(int argc, char* argv[])
{
bool useA=true;
if(useA)
using namespace A;
else
using namespace B;
cout << test << "\n";
return 0;
}