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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:36:05+00:00 2026-06-10T06:36:05+00:00

My aim is to set up a data structure to store the settings of

  • 0

My aim is to set up a data structure to store the settings of my application.

In PHP I would just write…

$settings = array(
    "Fullscreen" => true,
    "Width"      => 1680,
    "Height"     => 1050,
    "Title"      => "My Application",
);

Now I tried to create a similar structure in C++ but it can’t handle different datatypes yet. By the way if there is a better way of storing such settings data, please let me know.

struct Setting{ string Key, Value; };

Setting Settings[] = {
    ("Fullscreen", "true"),     // it's acceptable to store the boolean as string
    ("Width", "1680"),          // it's not for integers as I want to use them later
    ("Height", 1050),           // would be nice but of course an error
    ("Title", "My Application") // strings aren't the problem with this implementation
};

How can I model a structure of an associative array with flexible datatypes?

  • 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-10T06:36:06+00:00Added an answer on June 10, 2026 at 6:36 am

    An associative data structure with varying data types is exactly what a struct is…

    struct SettingsType
    {
        bool Fullscreen;
        int Width;
        int Height;
        std::string Title;
    } Settings = { true, 1680, 1050, "My Application" };
    

    Now, maybe you want some sort of reflection because the field names will appear in a configuration file? Something like:

    SettingsSerializer x[] = { { "Fullscreen", &SettingsType::Fullscreen },
                               { "Width",      &SettingsType::Width },
                               { "Height",     &SettingsType::Height },
                               { "Title",      &Settings::Title } };
    

    will get you there, as long as you give SettingsSerializer an overloaded constructor with different behavior depending on the pointer-to-member type.

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

Sidebar

Related Questions

AIM: I would like to set the below function to call every 5 seconds.
I am using PHP to iterate over the following result set, the aim is
The aim I would like to set such size for the DataGrid (standard, from
I just discovered that in Dojo there is no way to set an application-wide
I am trying to get an AIM Bot set up in C# and I
AIM: I would like to tail the last line of the file.txt and input
My aim is to create a status bar application which will draw drop down
I am set to create a file explorer using Java. The aim is to
First Some Background I'm planning out the architecture for a new PHP web application
I have a data set in R as follows ID Variable1 Variable2 Choice 1

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.