Understanding these terms in C++, Friend, Operator and Ostream.

JC0133

Senior member
Nov 2, 2010
201
1
76
How does these pre defined terms/functions work in C++.

Friend, Operator and Ostream.

What can you do or use these for?
 

Exophase

Diamond Member
Apr 19, 2012
4,439
9
81
friend: A class that's a friend of another class can access its private and protected members (the opposite is not automatically true)
operator: A symbol that describes an operation. For example, "+" is the addition operator. Operators can be "overloaded" so that their operation is customized depending on what sort of things (operands) it's operating on.
ostream: Output stream. Used to output a sequence of data to something like a file or the screen.
 

mv2devnull

Golden Member
Apr 13, 2010
1,521
155
106
Homework: something you do at the behest of an instructor so you learn the subject material. :)
That is usually interpreted a bit too narrowly to my liking.
Prime example: the "instructor" is self --> "no, this is not homework". Wrong. It is.

Herb Sutter's advice is to avoid having friends.

Operators are syntactic sugar, partly for the math fellows and partly to type less.
 

cabri

Diamond Member
Nov 3, 2012
3,616
1
81
Many US military programs will not allow the use of the FRIEND in code delivered
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
What did Encapsulation say to C++?

"I don't like friends playing with my private parts."