I managed to fix this problem, but now it seems that I'm still having a problem with overloading the " << " operator. I get an error message saying

no match for ‘operator<<’ in ‘cout << "("

What am I doing wrong here?? Again, any help would be appreciated, thanks!

[QUOTE=lonelycloud;1773007]I've been trying to write a class called Point, with a file Point.cpp including a header file Point.h . I tried to set a global variable of type Point called ORIGIN, however I get an error message saying "error: ‘ORIGIN’ does not name a type"

Point.h is as follows:
[ICODE]
// Point.h

//#include <iostream>

include <string>

include <cmath>

include <cstdlib>

ifndef POINT_H

define POINT_H

using namespace std;

class Point{

public:

    //Point(double a, double b);

    Point();

    void setPoint(Point &p, double a, double b);

    friend istream& operator>>(istream& cin, Point& p);

    friend ostream& operator<<(ostream& cout, const Point& p);

    friend double operator - (const Point& p1, const Point& p2);

    double x,y;

//private:    

    //double x,y;

};

extern Point ORIGIN;

istream& operator>>(istream& cin, Point& p);

ostream& operator<<(ostream& cout, const Point& p);

double operator - (const Point& p1, const Point& p2);

endif

[/ICODE]

Point.cpp is as follows:
[ICODE]
// Point.cpp

include "Point.h"

Point ORIGIN;

//ORIGIN = setPoint(ORIGIN,0,0);

ORIGIN.x = 0;

ORIGIN.y = 0;

void Point::setPoint(Point& p, double a, double b){

p.x = a;

p.y = b;

}

Point::Point(){

//setPoint(this,0,0);

}

istream& operator>>(istream& cin, Point& p){

string str, str_x, str_y;

int comma;

cin >> str;

comma = str.find(",");

str_x = str.substr(1,comma-1);

str_y = str.substr(comma,str.length()-3-str_x.length()); // -3 is from ...

I've been trying to write a class called Point, with a file Point.cpp including a header file Point.h . I tried to set a global variable of type Point called ORIGIN, however I get an error message saying "error: ‘ORIGIN’ does not name a type"

Point.h is as follows:
[ICODE]
// Point.h

//#include <iostream>

include <string>

include <cmath>

include <cstdlib>

ifndef POINT_H

define POINT_H

using namespace std;

class Point{

public:

    //Point(double a, double b);

    Point();

    void setPoint(Point &p, double a, double b);

    friend istream& operator>>(istream& cin, Point& p);

    friend ostream& operator<<(ostream& cout, const Point& p);

    friend double operator - (const Point& p1, const Point& p2);

    double x,y;

//private:    

    //double x,y;

};

extern Point ORIGIN;

istream& operator>>(istream& cin, Point& p);

ostream& operator<<(ostream& cout, const Point& p);

double operator - (const Point& p1, const Point& p2);

endif

[/ICODE]

Point.cpp is as follows:
[ICODE]
// Point.cpp

include "Point.h"

Point ORIGIN;

//ORIGIN = setPoint(ORIGIN,0,0);

ORIGIN.x = 0;

ORIGIN.y = 0;

void Point::setPoint(Point& p, double a, double b){

p.x = a;

p.y = b;

}

Point::Point(){

//setPoint(this,0,0);

}

istream& operator>>(istream& cin, Point& p){

string str, str_x, str_y;

int comma;

cin >> str;

comma = str.find(",");

str_x = str.substr(1,comma-1);

str_y = str.substr(comma,str.length()-3-str_x.length()); // -3 is from "(" "," and ")"

p.x = atof(str_x.c_str());

p.y = atof(str_y.c_str());

}

ostream& operator<<(ostream& cout, const Point& p){

cout << "(" << p.x << "," << p.y << ")";

}

double operator - (const Point& p1, const Point& p2){

double distance;

distance = sqrt( pow( (p2.x-p1.x),2) + pow( (p2.x-p1.x),2));

return distance; ...