Difficulty: Easy
Correct Answer: object
Explanation:
Introduction / Context:cout
is ubiquitous in C++ programs for console output. Understanding what it actually is clarifies why insertion with <<
works and how manipulators (like std::endl
) integrate with the streaming model in the standard library.
Given Data / Assumptions:
<iostream>
), not old *.h
forms.
Concept / Approach:
std::cout
is a global object of type std::ostream
(or an implementation-defined type derived from it) representing the standard output stream. The stream insertion operator operator<<
is overloaded for many types, enabling expressions like std::cout << 42
. Manipulators such as std::hex
and std::endl
are functions or objects that work with this stream object through overloads. It is not a function or macro itself; it is an instance through which output operations are performed.
Step-by-Step Solution:
<iostream>
: declared as an external stream object. 2) Recognize expression form: std::cout << value;
uses overloaded operators on the object. 3) Conclude: cout is an object, not a function, operator, or macro. 4) Understand that buffering and formatting are properties of the stream object.
Verification / Alternative check:
Intellisense/IDE hover shows cout’s type as std::ostream
. Taking its address &std::cout
is valid (object), while calling std::cout()
is ill-formed (not a function).
Why Other Options Are Wrong:
operator: <<
is the operator; cout is its left operand (an object).
function: you do not call cout; you stream into it.
macro: cout is not defined by the preprocessor.
Common Pitfalls:
std::endl
or std::flush
).
Final Answer:
object
Discussion & Comments