這不是我經常用C++工作,而是遇到了一個讓我困擾的簡單錯誤。C++頭文件/實現文件和重載運算符
在Xcode中,我有以下兩個錯誤: 在Event.h:Control reaches end of non-void function
在Event.cpp:Overloaded operator must have at least one argument of class or enumeration
兩個錯誤是在方法簽名的線
bool operator() (Event *left, Event *right)
這裏是完整的.h和.cpp文件(還沒有那麼多): Event.h
#ifndef __EventSimulation__EventComparison__
#define __EventSimulation__EventComparison__
#include <iostream>
#include "Event.h"
class EventComparison {
public:
bool operator() (Event *left, Event *right){}
};
#endif
Event.cpp
#include "EventComparison.h"
#include "Event.h"
bool operator() (Event *left, Event *right) {
return left->time > right->time;
}
有人可以幫我解決這個錯誤,並解釋什麼/爲什麼事情都發出編譯錯誤,以及如何避免這種情況的功能。謝謝你的幫助!
你錯過了在你的定義範圍內的分辨率。 – Freddy 2015-02-24 19:57:59