小编var*_*ick的帖子

重载<<运算符错误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. …
Run Code Online (Sandbox Code Playgroud)

c++ class operator-overloading

4
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

class ×1

operator-overloading ×1