Gets the number of vertices from the input If n <= MAX_VERTICES, fills m with data from file; otherwise signals failure on stream is and sets m size to 0 x 0

What will be an ideal response?


```
istream& operator>> ( istream& is, Digraph& d )
{
int i, j;

is >> d.n;
if (is.fail()) {
d.n = 0;
} else if (d.n > MAX_VERTICES) {
is.setstate( ios::failbit );
d.n = 0;
} else {
for (d.numEdges = 0;
d.numEdges < MAX_EDGES && !is.fail();
++d.numEdges)
is >> d.edges[d.numEdges][0] >> d.edges[d.numEdges][1];
--d.numEdges; // adjust numEdges
if (!is.eof()) {
d.n = 0;
}

}
return is;

}

```

Computer Science & Information Technology

You might also like to view...

A(n) ____ is a value used to guard the end of the series of values in an input loop.

A. dummy B. sentinel C. counter D. accumulator

Computer Science & Information Technology

A(n) __________ informs the compiler that a class will be declared later in the program.

a. static function b. private data member c. forward declaration d. object conversion e. None of these

Computer Science & Information Technology

Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value mapping is a __________ mapping.

a. many-to-many. b. many-to-one. c. one-to-many. d. one-to-one.

Computer Science & Information Technology

The following conditional expression is written in the C language. It is false when variable a is assigned either 10 or 20 and true otherwise.

!(a = = 10 a = = 20) Which of the following conditional expressions is equivalent? a) a != 10 II b !=20 b) a<=1011b>=20 c) a< 101Ia> 20 d) a = = 10 && a = = 20 e) a != 10 && a != 20 f) !(a = = 10) && !(a = = 20)

Computer Science & Information Technology