Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 856 Bytes

overloading-the-input-operator-for-your-own-classes.md

File metadata and controls

24 lines (19 loc) · 856 Bytes
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
operator>>
operator>>, overloading for your own classes
operator >>, overloading for your own classes
40dab4e0-3f97-4745-9cc8-b86e740fa246

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

Input Streams