| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Classes - Greater than less than operators
HI Guys,
I was just wondering how to make the greater than less than operators <> a friend on my class? I've allready made the extraction operators ie << >> for cin and cout. friend ostream& operator<<(ostream& out, date& tempDate); etc. do I have to have something like friend std:: operator<( ostream& in,& tempDate); I'm comparing an input from the keyboard with another value. I know that << and >> are part of the ostream library what are the < and > operators from. Any help greatly appreciated. regards Brendan |
|
#2
|
|||
|
|||
|
class x
{ friend bool operator< (const x&, const x&); }; This is only necessary if the non-member operator< requires access to private/protected members, though. If you can use some getvalue() member function to get the values you need for comparison, that may be preferrable. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Classes - Greater than less than operators |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|