Here is my class:
#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
All this function is supposed to do is out the values of a clock at different times.
ostream &operator<<(ostream &out, Clock &clockObj); 
should be
friend ostream &operator<<(ostream& out, Clock &clockObj);    
defined OUTSIDE the class.
See here: Should operator<< be implemented as a friend or as a member function?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With