What do these errors mean?
Vector.cpp:13: error: ISO C++ forbids declaration of ‘Vector’ with no type
Vector.cpp:13: error: explicit qualification in declaration of ‘void Vector::Vector(double, double, double)’
The C++ (Line 13 is the Vector::Vector( ...):
#include <iostream>
using namespace std;
namespace Vector
{
Vector::Vector( double x, double y, double z)
{
a = x;
b = y;
c = z;
}
/*
double Vector::dot(const Vector &v) const
{
return (a*v.a)+(b*v.b)+(c*v.c);
}
*/
Vector Vector::operator+(const Vector &v) const
{
Vector v1( a + v.a, b + v.b, c + v.c );
return v1;
}
Vector Vector::operator-(const Vector &v) const
{
Vector v1( a - v.a, b - v.b, c - v.c );
return v1;
}
bool Vector::operator==(const Vector &v) const
{
if( (a == v.a) && (b == v.b) && (c == v.c) )
{
return true;
}
else
{
return false;
}
}
Vector Vector::operator*(const Vector &v) const
{
Vector v1( b*v.c - c*v.b, c*v.a - a*v.c, a*v.b - b*v.a );
return v1;
}
ostream& operator<<(ostream &out, const Vector &v)
{
out << "<" << v.a << ", " << v.b << ", " << v.c << ">";
return out;
}
istream& operator>>(istream &in, Vector &v)
{
in >> v.a;
in >> v.b;
in >> v.c;
return in;
}
/*
double length( Vector v )
{
return sqrt( (v.a*v.a)+(v.b*v.b)+(v.c*v.c) );
}
*/
} // end namespace Vector
The header file:
#ifndef _VECTOR_H
#define _VECTOR_H
#include <cstdlib>
#include <iostream>
using namespace std;
namespace Vector
{
class Vector
{
private:
double a;
double b;
double c;
public:
Vector( double x=0.0, double y=0.0, double z=0.0);
double dot(const Vector &v) const;
Vector operator+(const Vector &v) const;
Vector operator-(const Vector &v) const;
bool operator==(const Vector &v) const;
Vector operator*(const Vector &v) const;
friend ostream& operator<<(ostream &out, const Vector &v);
friend istream& operator>>(istream &in, Vector &v);
}; // end Vector class
double length(Vector v);
} //end namespace Vector
#endif /* _VECTOR_H */