I have a question about the list class. The data consists of objects of the type intEntry
Here is my header file
Code:
class intEntry
{
public:
intEntry(int v, int c = 1);
// initalize the integer value and its count
int getValue() const;
// return value;
int getCount() const;
// return count
void increment();
// increment count
friend bool operator< (const intEntry& lhs, const intEntry& rhs);
friend bool operator== (const intEntry& lhs, const intEntry& rhs);
// compate lhs and rhs using value
friend ostream& operator<< (ostream& ostr, const intEntry& obj);
// output obj in format "value value ... value" (const times)
private:
int value;
// integer value;
int count;
// number of occurrences of value
};
My question is what those codes for
Code:
friend bool operator< (const intEntry& lhs, const intEntry& rhs);
friend bool operator== (const intEntry& lhs, const intEntry& rhs);
// compate lhs and rhs using value
friend ostream& operator<< (ostream& ostr, const intEntry& obj);
// output obj in format "value value ... value" (const times)
Why do I need to put a "friend" at the first?
Also, what is "operator<" ?
and (const intEntry& lhs) means the address of lhs?
Last one, What is the operator== for?
Thanks for helping.