Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:53:58+00:00 2026-06-18T06:53:58+00:00

How can I typedef/alias this into something more basic like ProjectInstance: ((ProjectType*)NamespaceOne::NamespaceTwo::ClassName::StaticVariable)->x=0; This is

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:53:59+00:00Added an answer on June 18, 2026 at 6:53 am

    call using directive locally?

    using namespace NamespaceOne::NamespaceTwo::NamespaceThree;
    // do something to StaticVariable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can have a typedef function pointer in a class like this: template<typename T>
Header files with declarations like this: void FooBar(System::Network::Win32::Sockets::Handle handle, System::Network::Win32::Sockets::Error& error /*, more fully-qualified
can someone explain me the compilation error in this code: #include common.h typedef struct
if I make a typedef someobject* pntr ; I can use this typedef to
I have this problem in C++: can I typedef a bitfield whose values come
On this question , there's an answer that states: You can use typedef to
I have never see a grammar in c++ like this before: typedef int (callback)(int);
Can someone convert this C struct to delphi as in record? typedef struct {
Can you explain for me what the typedef here is doing and what the
How can I convert the following struct to unsigned char* ? typedef struct {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.