Looking for an easy way to reinitialize a struct

后端 未结 2 1595
太阳男子
太阳男子 2021-01-24 07:43

I have a struct called CoolStruct:

struct CoolStruct

{
    int id;
    uint32 type;
    uint32 subtype;
    String name;
};

I have a vector of

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-24 08:16

    if you add a simple constructor:

    struct CoolStruct
    {
        CoolStruct(int id, uint32 type, uint32 subtype, String name) : id(id), type(type), subtype(subtype), name(name) {}
        int id;
        uint32 type;
        uint32 subtype;
        String name;
    };
    

    you can then do this:

    CoolVector.push_back(CoolStruct(1, EQData::EQ_EFFECT_TYPE_PARAMETRIC, 0, T("Parametric")));
    CoolVector.push_back(CoolStruct(2, EQData::EQ_EFFECT_TYPE_FILTER_LOW_PASS,EQData::EQ_FILTER_TYPE_FILTER_BUTTERWORTH_12DB, T("Low Pass")));
    

提交回复
热议问题