I am trying to find a way to group the main types and constants used by my project into a namespace, and then I'd like to import them in all my classes with "using namespace". I can't figure out why this piece of code doesn't compile, g++ error says:
expected nested-name-specifier before 'namespace'
What options do I have to have all my types and constants grouped together? I tried making Traits a struct and then using inheritance but this gives problems with templates, another way is writing in all classes something like:
using scalar_t = Traits::scalar_t;
Thanks for any tip.
#include <iostream>
namespace Traits {
constexpr int N = 3;
using scalar_t = double;
};
struct Entity {
using namespace Traits; // problems here
scalar_t foo() const;
int n = N;
};
scalar_t Entity::foo() const { return N; } // problems here
int main()
{
Entity e;
e.foo();
return 0;
}