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
?