-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvect.h
43 lines (41 loc) · 910 Bytes
/
vect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef VECTOR_H_
#define VECTOR_H_
#include<iostream>
namespace VECTOR
{
class Vector
{
private:
//data field
double x;
double y;
double mag;
double ang;
char mode;
//private method
void set_mag();
void set_ang();
void set_x();
void set_y();
public:
Vector();
Vector(double n1,double n2, char form ='r');\
void sett(double n1, double n2, char form = 'r');
~Vector();
double xval() const {return (x);};
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);
//friends
friend Vector operator*(double n, const Vector &a);
friend std::ostream &operator<<(std::ostream, const Vector &v);
};
}
#endif