I am wondering why the following code of a far-fetched example works fine in Visual Studio 2005, but it generates an error in GCC ("there is no corresponding function to call" when Interpolate () is called, as shown below).
Also, how do I get around this? It seems that the error message is just a general message because GCC did not have a more specific message about the actual cause of the problem, and it had to output something. I don't understand a bit how to continue porting this class without any ugly workarounds.
namespace Geo
{
template <class T>
class TMyPointTemplate
{
T X,Y;
public:
inline TMyPointTemplate(): X(0), Y(0) {}
inline TMyPointTemplate(T _X,T _Y): X(_X), Y(_Y) {}
inline T GetX ()const { return X; }
inline T GetY ()const { return Y; }
template<T> TMyPointTemplate<T> Interpolate(const TMyPointTemplate<T> &OtherPoint)const
{
return TMyPointTemplate((X+OtherPoint.GetX())/2,(Y+OtherPoint.GetY())/2);
}
};
typedef TMyPointTemplate<int> IntegerPoint;
}
Geo::IntegerPoint Point1(0,0);
Geo::IntegerPoint Point2(10,10);
Geo::IntegerPoint Point3=Point1.Interpolate(Point2);
Thank you for your help,
Adrian
source
share