I have a question about the list class. The data consists of objects of the type intEntry
Here is my header file
My question is what those codes forCode: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 };
Why do I need to put a "friend" at the first?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)
Also, what is "operator<" ?
and (const intEntry& lhs) means the address of lhs?
Last one, What is the operator== for?
Thanks for helping.
![]()
![]()



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.