Continue to my last question i am facing one more issue regarding Pass a Vector of structure to a function with void * as in parameter
#include <iostream>
#include <vector>
struct MMT
{
int a;
char b;
int * data;
}
int func(void *structPtr){
//use the structure member
}
int main ()
{
std::vector<MMT*> myvector;
for (int i=1; i<=5; i++){
MMT *mmt;
mmt->a = i;
mmt->b = 'a';
myvector.push_back(MMT);
}
std::cout << "myvector contains:";
for (std::vector<int*>::iterator it = myvector.begin() ; it !=myvector.end(); ++it)
{
func((void*)it);//?????????//how to pass structure
}
std::cout << '\n';
return 0;
}
I am getting Null pointer error