We are interested in providing a class, say class A, with an overloaded operator<< for output. You can’t put a using directive or declaration in a function header. There are three ways to make namespace names available in a declaration of an overloaded operator<<. Give two of the three ways to declare an overloaded operator <<. Give the #include, assume that class A has been defined, then define a stand-alone operator<< function for output of a class. Only give the two declarations, not the implementation, of such overloaded functions.

What will be an ideal response?


An answer that qualifies ostream is
```
#include
// assume class A has been defined
std::ostream& operator<<(std::ostream& outStr,
```

This answer makes only the name ostream available using declaration:
```
#include
// assume class A has been defined
using std::ostream;
ostream& operator<< (ostream& outStr,
const A & ObjectOut);
```

Yet another that uses a using directive is:
```
#include
// assume class A has been defined
using namespace std;
ostream& operator<< (ostream& outStr,
const A & ObjectOut);
```

Computer Science & Information Technology

You might also like to view...

For each of the following expressions, indicate the order in which the operators will be evaluated by writing a number beneath each operator.

a. a – b – c – d b. a – b + c – d c. a + b / c / d d. a + b / c * d e. a / b * c * d f. a % b / c * d g. a % b % c % d h. a – (b – c) – d i. (a – (b – c)) – d j. a – ((b – c) – d) k. a % (b % c) * d * e l. a + (b – c) * d – e m. (a + b) * c + d * e n. (a + b) * (c / d) % e

Computer Science & Information Technology

Before clicking the Columns button, it is best to select the text that you want to format as columns

Indicate whether the statement is true or false

Computer Science & Information Technology

The TCP protocol is used at the _______ layer of the OSI model

a. Application b. Presentation c. Network d. Transport

Computer Science & Information Technology

Which of the following is the correct syntax for the Insert method?

A. insert.String(startIndex, value) B. insert.String(value, startIndex) C. string.Insert(value, startIndex) D. string.Insert(startIndex, value)

Computer Science & Information Technology