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

  • SEARCH
  • Home
  • 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 916951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:07:54+00:00 2026-05-15T18:07:54+00:00

Simple question, how do I shorten a call/name without using defines. For example, I

  • 0

Simple question, how do I shorten a call/name without using defines.

For example, I have a singleton that I have to call that is within a namespace (I cannot use using namespace blabla because it is not allowed) like so:

MyFW::GameRoot::Instance()->DoSomething();

Now I can assign that to a variable, which works somewhat if I am using it multiple times within the same class/function, but using it in many classes/functions it becomes cumbersome. I decided to use #define for it:

#define MyFW::GameRoot::Instance() ROOT //defined in GameRoot.h

ROOT->DoSomething(); //Used where-ever GameRoot.h is included

Much better, and I really like it especially because now wherever I see ROOT (color coded through V-Assist) I know what it is immediately… unless I have a breakpoint there and I need Visual Studio to resolve ROOT to show up in the watch window (or even hover over it to quickly pull up the object in debug), which it cannot do.

Is there any other option? What do you guys do to shorten names? Simply use local/member pointers to store the instance?

Thanks!

  • 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-05-15T18:07:55+00:00Added an answer on May 15, 2026 at 6:07 pm

    If you want to ease access across multiple functions, just use a helper function:

    namespace {
        MyFW::GameRoot* root() { return MyFW::GameRoot::Instance(); }
    }
    
    // ...
    root()->DoSomething();
    

    Two characters more, but it with comes type-safety included.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple question. Is there a built in method to shorten
simple question about intent action naming convention: I have a new service that handles
Simple question that we've spent to much time on. We have a server side
A. Simple question. I have 3 instances of Repository that depends on the Configuration.
Simple question: Is there a class or interface that encapulates the getting of a
Simple question - How do I convert a string that has been through parseInt
Simple question: does the Java memory/synchronization model guarantee atomic pointer writes? That is, if
Simple question: I call: DateTime.TryParseExact(May 16 13:47:12 2012, MMM dd hh:mm:ss yyyy, System.Globalization.CultureInfo.GetCultureInfo(en-US), DateTimeStyles.None,
Simple question I hope.... I have a Win Form with a Tab Control and
I have a very simple question and would be great if someone could save

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.