Which of the following is known as insertion operator?
Select one:
A. ^
B. V
C . <<
D. > >
Answers
Answer:
The insertion ( << ) operator, which is preprogrammed for all standard C++ data types, sends bytes to an output stream object. Insertion operators work with predefined "manipulators," which are elements that change the default format of integer arguments.
Explanation:
The statement cout<<“Hello”; is an overloaded statement that overloads the operator <<. This operator also has two operands count (object of output stream) and a string “Hello”. The second operand may be either a string, a variable, or a number.
The purpose of this statement is to print the string “Hello” to the screen. When this statement is executed it calls the overloaded operator >>() function. The value returned by this function is an object of the output stream (stream).
Both the overloaded operator functions return a stream. The symbol ‘&’ at the end of the name of the stream represents that the operator function returns a reference i.e., it returns an object of the stream rather than returning the value of the stream itself.
The program below illustrates the operation of overloading both the insertion and extraction operators.
#SPJ2