Click here to Skip to main content
15,886,724 members

Response to: dynamic array of interfaces

Revision 1
Solution using std::vector...

Declare this somewhere
C++
std::vector<myinterface> InterfaceList;</myinterface>


Too add an interface...
C++
MyInterface *pNewInterface;
pNewInterface = new MyClass;
if (pNewInterface )
   push_back(pNewInterface);
}


To iterate through the interfaces
C++
size_t n = InterfaceList.size();
for (size_t i=0; i < n; i++) {
    InterfaceList[i]->myFunction();
}


Then to delete them later...
C++
size_t n = InterfaceList.size();
for (size_t i=0; i < n; i++) {
    delete InterfaceList[i];
}
InterfaceList.clear();
Posted 21-Sep-12 8:29am by JackDingler.
Tags: