Imcompatible type, const and const
Duarte
xporg.roso at gmail.com
Sun Mar 9 09:15:34 PDT 2014
Hi guys,
While I was out there, trying some D and stuff, I came with an
error message I can't understand.
Let's assume I have something like:
class Point2
{
Vector2 opBinary(string op)(const Point2 _right)
{
static if(op == "-")
{
return new Vector2( this.x - _right.x,
this.y - _right.y );
}
}
public static float DistanceSq(const Point2 _left, const
Point2 _right)
{
return _left.DistanceSq(_right);
}
public float Distance(const Point2 _right) const
{
Vector2 vec = this - _right;
[...]
}
}
The line "Vector2 vec = this - _right" is giving me the following
error:
Error: incompatible types for ((this) - (_right)):
'const(Point2)' and 'const(Point2)'
What am I missing here? The same code in C++ compile, so I was
assuming it would just as well compile in D.
Cheers!
More information about the Digitalmars-d-ide
mailing list