Problem overloading input operator

Greetings. This one has me stumped. So it's probably something obvious! I am trying to overload the input operator using a friend function. I have managed to trim my program down to the bare minimum. I think the code pretty much speaks for itself. The code below compiles OK but when I run it I get the following output in my console window. It doesn't let me input the point.

Process returned -1073741819 (0xC0000005) execution time : 0.120 s

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
#include <iostream>
using namespace std;

class Point
{
private:
    double x, y, z;

public:
    Point( double x=0.0, double y=0.0, double z=0.0 )
    {
        this->x = x;
        this->y = y;
        this->z = z;
    }

    friend istream& operator>>( istream &, const Point & );
};

istream& operator>>( istream &in, const Point &p )
{
    in >> p.x >> p.y >> p.z;

    return in;
}

int main()
{
    Point p;
    cin >> p;

    return 0;
}
never mind I found the problem. I can't make the Point parameter a const
Topic archived. No new replies allowed.