I have a class called CoolMenuItems
class CoolMenuItems
{
public:
CoolMenuItems();
~CoolMenuItems();
struct MenuItemOne
{
int id;
uint32 type;
uint32 subtype;
String name;
};
struct MenuItemTwo
{
uint32 subtype;
String name;
};
}
This is just the bare bones of the class… I want to have two arrays, one of MenuItemOne, and one of MenuItemTwo, and these arrays would have the following. These arrays I want to initialize like:
MenuItemOne a[] =
{
{1, EQData::EQ_EFFECT_TYPE_PARAMETRIC, 0, T("Parametric")},
{2, EQData::EQ_EFFECT_TYPE_FILTER_LOW_PASS, EQData::EQ_FILTER_TYPE_FILTER_BUTTERWORTH_12DB, T("Low Pass")},
};
MenuItemTwo b[] =
{
{EQData::EQ_FILTER_TYPE_TRHU, T("Thru")},
{EQData::EQ_FILTER_TYPE_BUTTERWORTH_6DB, T("6 dB Butterworth")},
};
only, with more elements than just two…
I want to set it up so that I can create a new CoolMenuItems object with
CoolMenuItems *cmi = new CoolMenuItems();
so that I can access those array elements via
cmi->a[1];
Can you modify your code like this
So that you can initialize the elements of struct and push_back the struct into the std::vector, all the memory to be allocated and to be freed will be taken care of by the std::vector
Similarly for MenuItemTwo.
If you have a different requirement then please give more details.