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 7218611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:30:20+00:00 2026-05-28T21:30:20+00:00

I have a c++ application. I need to load some config data from file.

  • 0

I have a c++ application. I need to load some config data from file.

The structure is:

Root(singleton) → ConfigManager(); LogManager(); ...;

So all managers are created in Roo’ts ctor and I can get pointers to them using method: Root::Get().GetSomeManager();

int main()
{
    // Here all managers are initialized
    Root::Get();
    // App cycle
    Root::Get().Deinitialize();

    return 0;
}

ConfigManager allows me to load from file values by passed key.

The question is:
How can I store values from file in some global extra file?

I wrote file Config.hpp with code which looks like:

const int val = Root::Get().GetConfig()->GetValue("Key");

The problem is that this file is possibly could be included before the Config manager is initialized, or not?

I know this code is bad, but I don’t know how to write it better.

  • 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-28T21:30:21+00:00Added an answer on May 28, 2026 at 9:30 pm

    From what I understand you want to store config settings in memory on application startup so that you don’t need to access config file in runtime. But why have you decided to use global variables for it when you have singleton like that already?

    I would store these settings as private attributes of ConfigManager and initialize them as a part of initialization of ConfigManager. And then when something like Root::Get().GetConfig()->GetValue("Key") is called, it would return value of one of these private attributes already.

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

Sidebar

Related Questions

In my Windows phone7 application I load some data from a XML feed. Some
I need to have a Win32 application load a hard coded AES-256 key, ideally
I have this application that need to do some things in protected paths (like
I have a java application I need to pass some info to a C++
I have an application where I need to INSERT an auto_increment value from a
Hokay so I have an application where I need some IPC... I'm thinking named
I have a page in my application where i need to load two css
I have a .Net windows forms application, and I need to load values into
I have a Form in my application that displays some data. When I first
I have two application that need to talk to each other. App1 needs to

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.