我的目标是建立一个数据结构来存储我的应用程序的设置。
在 PHP 中,我只会写...
$settings = array(
    "Fullscreen" => true,
    "Width"      => 1680,
    "Height"     => 1050,
    "Title"      => "My Application",
);
现在我尝试在 C++ 中创建一个类似的结构,但它还不能处理不同的数据类型。顺便说一句,如果有更好的方法来存储这些设置数据,请告诉我。
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
};
如何为associative arraywith的结构建模flexible datatypes?