Operator overloading issue.

Good evening.

I'm making a Line class and whilst overloading a few operators I ran into some issues.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 istream& operator>>(std::istream& in, const Line& ln)
{
	double slope, intercept;
	cin >> slope;
	cin >> intercept;
	ln = Line(slope, intercept); //error occurs here
	return in;
}

Line& Line::operator= (const Line &lSource)
{
	if(this == &lSource)
		return *this;

    m = lSource.getIntersept();
	b = lSource.getSlope();
 
    return *this;
}


And the error being:
 
Error	4	error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Line' (or there is no acceptable conversion)	


Any idea whats going on?
Make ln not const in operator>>.
Last edited on
Oh that was dumb.Thanks for the help mate!
Last edited on
Is there two doubles to read? Otherwise cin will wait until there are.
Topic archived. No new replies allowed.