description | title | ms.date | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|
Learn more about: Overloading the >> Operator for Your Own Classes |
Overloading the >> Operator for Your Own Classes |
11/04/2016 |
|
40dab4e0-3f97-4745-9cc8-b86e740fa246 |
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;
}