Operator overloading fails

Hello,
I'm trying to make a very simple class, but it doesn't work, and I don't know why!

GraphPoint.h:
1
2
3
4
5
6
7
8
9
#ifndef _GRAPHPOINT_H
#define _GRAPHPOINT_H
class GraphPoint
{
public:
	double x,y;
	bool operator< (const & GraphPoint in_lh) const;
};
#endif 


graphpoint.cpp:
1
2
3
4
5
#include "GraphPoint.h"
bool GraphPoint::operator< (const & GraphPoint in_lh) const
{
	return (x < in_lh.x);
}


Now, Upon compillation I get these error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(this refers to the bool return type)...
error C2146: syntax error : missing ',' before identifier 'in_lh'
error C2065: 'in_lh' : undeclared identifier
error C2228: left of '.x' must have class/struct/union

for sanity I've tried compiling this:
1
2
3
4
bool func()
{
    return true;
} 

and it compiled just fine...
Whats going on?!
Last edited on
missing a semicolon at the end of your class

1
2
3
4
class GraphPoint
{
  //...
};  // <- semicolon 
Last edited on
Thanks for the quick reply...
I wrote it wrong here (will update the original post).
But my code had the semicolon...
Try again :)

It does not work even like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef _GRAPHPOINT_H
#define _GRAPHPOINT_H

class GraphPoint
{
public:
	double x,y;
	bool operator< (const & GraphPoint in_lh) const
	{
		return (x < in_lh.x);
	}
};

#endif 


same errors...
Last edited on
Because you're doing const & GraphPoint instead of const GraphPoint &
Topic archived. No new replies allowed.