How can I typedef/alias this into something more basic like ProjectInstance:
((ProjectType*)NamespaceOne::NamespaceTwo::ClassName::StaticVariable)->x=0;
This is a static class and calling it by namespace+casting it every time is annoying.
How can I simplify this into an alias of some sort so I can just refer to it as
ProjectInstance->x=0;
I was originally thinking something along these lines:
#typedef ((ProjectType*)NamespaceOne::NamespaceTwo::ClassName::StaticVariable) ProjectInstance
Where ProjectInstance is the alias for StaticVariable casted into ProjecType*.
NamespaceOne::NamespaceTwo::ClassName::StaticVariable
StaticVariable is an instance of BaseType. ProjectType extends BaseType, I am simply casting StaticVariable to ProjectType because there is an additional variable “x” in ProjectType class.
What I am trying to avoid:
Declaring a pointer/function in each class where I need to access this static variable.
So far the solution is “using namespace”, while I was aware of this before, it’s the best posted solution so far.
So we cut our original line of code into:
((ProjectType*)ClassName::StaticVariable)->x=0;
I have another solution:
ClassName::ProjectStaticVariable->x=0;
By creating a new pointer inside the “ClassName” class I was able to cut it down even more.
Are there any better ways to cut this down even further?
call
using directivelocally?