Here is my example
Why I get this error and how I fix it? I want to understand why this happens.Code:#include <iostream> #include <vector> using namespace std; class Point3d { public: /** * Constructor with given value that will be set to all coordinates. * @param v - the value */ Point3d( double v ) : _x( v ), _y( v ), _z( v ) {}; /** * Returns the first coordinate of this point (constant). * @return the \b first coordinate */ const double x() const { return _x; }; /** * Returns the second coordinate of this point (constant). * @return the \b second coordinate */ const double y() const { return _y; }; /** * Returns the third coordinate of this point (constant). * @return the \b third coordinate */ const double z() const { return _z; }; /** * Multiply all coordinates of this point with the given value. * @param w - the multiplier */ void operator *= ( const double w ) { _x *= w; _y *= w; _z *= w; }; bool operator >= ( const Point3d& p ) { return ( _x >= p.x() && _y => p.y() && _z => p.z() ); }; private: double _x; double _y; double _z; }; int main() { Point3d q(2); Point3d w(1); if(q>=w) cout<<"OK\n"; return 0; }
I thought, going on like with the other operator I overloaded, *=, would work just fine...Code:main.cpp: In member function `bool Point3d::operator>=(const Point3d&)': main.cpp:44: error: expected primary-expression before '>' token main.cpp:44: error: expected primary-expression before '>' token