Extend the following class definition so it overloads the input and output operators.

```
class Vect {
public:
Vect () {}
Vect ( double, double );
private:
double r; // magnitude
double theta; // direction (radians)
};
//
// Constructor 2: Initializes all components
//
Vect :: Vect( double vectMag, double vectDir )
{
r = vectMag;
theta = vectDir;
}
```


```
class Vect {
public:
Vect () {}
Vect ( double, double );
private:
double r; // magnitude
double theta; // direction (radians)
friend istream& operator>> ( istream&, Vect& );
friend ostream& operator<< ( ostream&, const Vect& );
};
//
// Constructor 2: Initializes all components
//
Vect :: Vect( double vectMag, double vectDir )
{
r = vectMag;
theta = vectDir;
}
//
// Input a Vect object
//
istream& operator>> ( istream& in, Vect& v )
{
in >> v.r >> v.theta;
return in;
}
//
// Display a Vect object
//
ostream& operator<< ( ostream& out, const Vect& v )
{
out << "radius = " << v.r << ", theta = " << v.theta;
return out;
}
```

Computer Science & Information Technology

You might also like to view...

Answer the following statements true (T) or false (F)

1. Along with managing time and resources, systems analysts must also manage people. 2. By comparing costs alone, the systems analyst can use break-even analysis to determine the break-even capacity of the proposed information system. 3. Intangible costs are those that can be accurately projected by the systems analyst and the business's accounting personnel. 4. Tangible costs include losing a competitive edge, losing the reputation for being first with an innovation or the leader in a field, declining company image due to increased customer dissatisfaction, and ineffective decision making due to untimely or inaccessible information. 5. When assembling a team, a project manager should look for people with both experience and enthusiasm.

Computer Science & Information Technology

Brianna has developed a new device to be used by people with physical disabilities. Brianna's device can be classified as _____.

A. ?cloud hardware B. ?assistive hardware C. ?networking hardware D. ?flash-drive hardware

Computer Science & Information Technology

____ is an extra array used during the merge process.

A. mergeSortHelper B. tempSpace C. copyBuffer D. mergeBuffer

Computer Science & Information Technology

To initialize a set of nested structures, the values for each set are enclosed in a separate set of braces, separated by commas, and the entire set is enclosed in a set of braces.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology