我正在尝试使用向量迭代器打印出向量中的所有元素。我查找了类似的问题,但发布的解决方案似乎对我不起作用。这是代码:
void printPerms()
{
for(vector<process>::iterator it = allProcesses.begin(); it != allProcesses.end(); it++)
{
for(int i = 0; i < numResourceTypes; i++)
{
cout << (static_cast<process*>(*it).need) << (static_cast<process>(*it)).allocated <<endl;
}
}
}
还有我遇到的错误,我不知道如何解决:
error C2440: 'static_cast' : cannot convert from 'process' to 'process *' No user
defined-conversion operator available that can perform this conversion, or the operator
cannot be called
error C2228: left of '.need' must have class/struct/union