I get the error "First Defined Here" for all my overloaded operators.
I have not declared those overloaded operators anywhere else and I cannot find out what is happening
My code (this is the header file):
#ifndef VECTOR_H
#define VECTOR_H
#include <iostream>
using namespace std;
class Vector
{
public:
Vector();
double Getx();
double Gety();
double Getz();
void Setx(double a);
void Sety(double b);
void Setz(double c);
friend ostream &operator<<(ostream &mystream, Vector &v);
friend istream &operator>>(istream &mystream, Vector &v);
private:
double x, y, z;
};
bool operator==(Vector a, Vector b)
{
return (a.Getx() == b.Getx() && a.Gety() == b.Gety() && a.Getz() == b.Getz());
}
bool operator!=(Vector a, Vector b)
{
return !(a==b);
}
Vector operator+(Vector a, Vector b)
{
double k = a.Getx() + b.Getx();
double l = a.Gety() + b.Gety();
double m = a.Getz() + b.Getz();
Vector v;
v.Setx(k);
v.Sety(l);
v.Setz(m);
return v;
}
double operator*(Vector a, Vector b)
{
double r = a.Getx()*b.Getx() + a.Gety()*b.Gety() + a.Getz()*b.Getz();
return r;
}
Vector operator*(Vector a, float b)
{
Vector v;
v.Setx(v.Getx()*b);
v.Sety(v.Gety()*b);
v.Setz(v.Getz()*b);
return v;
}
ostream &operator<<(ostream &mystream, Vector &v)
{
mystream<<v.x<<", "<<v.y<<", "<<v.z<<endl;
return mystream;
}
istream &operator >> (istream &mystream, Vector &v)
{
cout<<"Enter x, y, z: ";
mystream>>v.x>>v.y>>v.z;
return mystream;
}
#endif // VECTOR_H
The declarations in the .cpp file are only for the constructor, the getters and the setters so I cannot understand where I have declared the overloaded operators another time.