Current location - Quotes Website - Signature design - Please advise on the overloading of C++ input and output operators.
Please advise on the overloading of C++ input and output operators.
Test with your program

# include & ltiostream & gt

# include & lt string & gt

Use namespace std

Fruits

{

Public:

Fruit (constant string & ampnst = "Apple", constant string & ampcst = "green "): name (nst), color (cst){}

~ Fruit () {}

Friends of Oysters & Operator & lt& lt(ostream & ampos, const Fruit & amp);

Private:

String name; String color;

};

Oyster &; Operator & lt& lt(ostream & ampos, const Fruit & ampf)

{

Os<& lt "name is"<& ltf.name & lt& lt. color is "<& lt color & lt& ltendl.

Return to OS;

}

int main()

{

Fruit apple;

Cout & lt& lt apples;

Returns 0;

}

authorized strength

G++ BD. c-o 1- wall

run quickly

. / 1

The name is Apple. The color is green.

No error

G++(GCC)2008 1 105 (Red Hat 4.3.2-7)

Copyright (C) 2008 Free Software Foundation.

This is free software; See the source for reproduction conditions. not have

Warranty; Not even for marketability or fitness for a particular purpose.

What compiler does the landlord use?