Inherited struct members inaccessible during aggregate initialization

  aggregate-initialization, c++, inheritance, struct
struct BasePluginInfo
{
    bool bHasGui, bIsSynth;
    char cType;
    std::string sCategory, sSdkVersion, sVendor, sVersion;
};

struct PluginClassInfo
{
    std::string sName, sUid;
    std::vector<std::string> vsParamNames;
};

struct ShellPluginInfo : BasePluginInfo
{
    std::vector<PluginClassInfo> vciClasses;
};

When I do

ShellPluginInfo
{
    .bHasGui = true
};

The compiler complains that ShellPluginInfo has no field 'bHasGui'.

However this works:

ShellPluginInfo info;
info.bHasGui = true;

SO complains I have too much code, so these are a few words to fill it up.

Source: Windows Questions C++

LEAVE A COMMENT