Overloading the >>
Operator for Your Own Classes
Input streams use the extraction (>>
) operator for the standard types. You can write similar extraction operators for your own types; your success depends on using white space precisely.
Here is an example of an extraction operator for the Date
class presented earlier:
istream& operator>> (istream& is, Date& dt)
{
is>> dt.mo>> dt.da>> dt.yr;
return is;
}
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for