Here is a list of the errors and the code afterward.
If we can figure out the first errors the other error is just the same thing.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
vector.cpp:
Error E2061 vector.cpp 36: Friends must be functions or classes
Error E2139 vector.cpp 36: Declaration missing ;
Error E2321 vector.cpp 37: Declaration does not specify a tag or an identifier
Error E2061 vector.cpp 37: Friends must be functions or classes
Error E2139 vector.cpp 37: Declaration missing ;
Error E2321 vector.cpp 38: Declaration does not specify a tag or an identifier
*** 6 errors in Compile ***
Code:
//vector.cpp example 10.11 pg 446 C++ primer plus
#ifndef _VECTOR_CPP_
#define _VECTOR_CPP_
class Vector
{
private:
double x;
double y;
double mag; //magnitude, length of vector
double ang; //direction of vector
char mode; // 'r'=rectangular, 'p'=polar
// private methods for setting values
void set_mag();
void set_ang();
void set_x();
void set_y();
public:
Vector();
Vector(double n1, double n2, char form='r');
void set(double n1,double n2, char form='r');
~Vector();
double xval() const {return x;} // inline return x val
double yval() const {return y;}
double magval() const {return mag;}
double angval() const {return ang;}
void polar_mode();
void rect_mode();
// operator overloading
Vector operator+(const Vector & b) const;
Vector operator-(const Vector & b) const;
Vector operator-() const;
Vector operator*(double n) const;
// friends
friend vector operator*(double n, const Vector & a); // errors start here
friend ostream & operator<<(ostream & os,const Vector & v);
};
#endif