让我们上课:
class lineCommand {
public:
lineCommand(float startTime, float endTime);
virtual ~lineCommand();
//those are short inline functions:
//setting the starting time of the command
void setStartTime(const float num){mStartTime=num;};
//setting the ending time of the command
void setEndTime(const float num){mEndTime=num;};
// returning the starting time of the command
float getStartTime() {return mStartTime;};
// returning the ending time of the command
float getEndTime() const {return mEndTime;};
private:
float mStartTime;
float mEndTime;
};
然后我们创建这个类的向量
std::vector<lineCommand> mAllCommands;
但是当我尝试使用该向量的迭代器时,就像那样:
bool simulationTool::mSettingStartingTime(float startingTime){
std::vector<lineCommand>::iterator tempIterator=mAllCommands.begin();
while (tempIterator!=mAllCommands.end() && (*tempIterator).getStartTime()<startingTime){
mActiveCommands.push_back(&(*tempIterator));
tempIterator++;
}
}
我在日食中遇到错误
invalid type argument of unary ‘*’ (have ‘float’)
在&#34; (* tempIterator).getStartTime()
std::vector<lineCommand> mAllCommands;
std::vector<lineCommand*> mActiveCommands;