I've stumbled across this GitHub Project.
While I don't agree with the code in general I can't wrap my mind about the line:
QProcess *p;
and p=*it;
Am I wrong when I feel like creating a new pointer there is completely redundant or is there some purpose of it I'm missing for example performance wise?
#define VM_COUNT 202
cout << "Creating process objects" << endl;
for(int i=0;i<VM_COUNT; i++)
vms.push_back(new QProcess(parent));
cout << "Processes created. Type 'asdf' or someting to start them...";
string s;
cin >> s;
cout << "Starting processes" << endl;
QProcess* p; // this <------
QVector<QProcess*>::Iterator it;
for(it=vms.begin(); it!=vms.end(); ++it){
p=*it; // this <------
p->start(command,args); // this <------
}
I would simply go with:
for(it=vms.begin(); it!=vms.end(); ++it)
{
(*it)->start(command,args); // ty Mike
}