這裏是我的類:重載<<操作錯誤C2804:二進制「操作符<<」有太多的參數
#ifndef CLOCK_H
#define CLOCK_H
using namespace std;
class Clock
{
//Member Variables
private: int hours, minutes;
void fixTime();
public:
//Getter & settor methods.
void setHours(int hrs);
int getHours() const;
void setMinutes(int mins);
int getMinutes() const;
//Constructors
Clock();
Clock(int);
Clock(int, int);
//Copy Constructor
Clock(const Clock &obj);
//Overloaded operator functions
void operator+(const Clock &hours);
void operator+(int mins);
void operator-(const Clock &hours);
void operator-(int minutes1);
ostream &operator<<(ostream &out, Clock &clockObj); //This however is my problem where i get the error C2804. Saying that it has to many parameters
};
#endif
所有這些功能是應該做的是從一個時鐘的值在不同的時間。
它有三個參數。它應該有兩個。 – chris
爲了將來的參考,請在發佈代碼塊時不要使用代碼高亮反引號。這裏有一個單獨的按鈕(或者你簡單地用4個空格縮進每一行) – paddy