Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN C++ , 7) TRUE / FALSE The << and >> operators have already been overloaded by

ID: 3840306 • Letter: I

Question

IN C++ ,

7) TRUE / FALSE The << and >> operators have already been overloaded by the stream classes! TRUE/FALSE Originallytheywereusedtomultiplyanddivideintegertypesby .

8) Name at least three operators which cannot be overloaded. (Reminder: there were 5 — or 6 depending on how you count that one — operators that are not overload-able.)

9) TRUE / FALSE A type must be programmer-defined for operators to be overloaded for it. TRUE / FALSE This at least includes classes and enumerations.

10) Explain the general use of the seekg and tellg methods in stream processing.

11) Whenistheeofflagraised(set/on)inaninputstreamobject?(Thereisonlyoneconditionthatcausesthis...)

What about the fail flag? When is it raised (set/on) in an input stream object? (There are at least three — 3 — conditions that can cause this. . . )

12) Stream formatting methods can be used by including the library in your pro- gram. The formatting manipulators, however, require inclusion of the library header.

13) TRUE / FALSE If you forget to close a file stream, nothing could possibly go wrong.

14) You are given a class Class which has the array member arr (which is of base type bool) whose used entries are counted by member count (which is of type size t). Show (pseudo)code for operatorr s to be used to access the elements of arr from a Class object. (Hint: How many operator functions does it take to fully overload operatorr s?)

Explanation / Answer

Answer7) TRUE

The operators ‘<<' and '<<' are called like 'cout << ob1' and 'cin << ob1'. So if we want to make them a member method, then they must be made members of ostream and istream classes, which is not a good option most of the time. Therefore, these operators are overloaded as global functions with two parameters, cout and object of user defined class.

TRUE : Originally << and >> operators were used to multiply and divide integer types

Answer 8)

The following operators can not be overloaded:

:: (Scope Resolution Operator)
. (Member Access or Dot operator)
.* (Pointer-to-member Operator )
?: (Ternary or Conditional Operator )
sizeof (Object size Operator)
typeid (Object type Operator)

Answer 9) FALSE

TRUE: operators overloading at least includes classes and enumerations.

Answer 10)

seekp() :

This method changes the location of a stream object's file pointer for output (put or write.) In most cases, seekp also changes the location of a stream object's file pointer for input (get or read.)
seekp ( position );

tellg() :

This function is used with input streams, and returns the current "get" position of the pointer in the stream.