【发布时间】:2013-10-08 23:43:23
【问题描述】:
顺便说一句,我在 arch linux 上使用 eclipse 和 g++(我在不到一周前运行了 pacman -Syu,所以一切都是最新的)。
每次我尝试编译时,Eclipse 都会产生一个错误:
#ifndef DATE_HPP_
#define DATE_HPP_
using namespace std;
class Date {
public:
int Year;
char Month;
char Day;
char HH;
char MM;
char ss;
Date();
/*
* Overloaded Operator Functions
*/
//Assignments
Date operator=(Date input);
//Comparisons
bool operator==(Date& rhs);
bool operator!=(Date& rhs);
bool operator<(Date& rhs);
bool operator>(Date& rhs);
bool operator<=(Date& rhs);
bool operator>=(Date& rhs);
//Conversion
operator char*();
operator std::string();
ostream& operator<<(ostream& os, const Date& date); //TROUBLE LINE
};
#endif /* DATE_HPP_ */
Eclipse 在 operator
ostream& operator<<(const Date& date);
它抱怨它必须有两个。我做错了什么?
【问题讨论】:
标签: c++ operator-overloading iostream