1>c:\users\administrator\documents\visual studio 2010\projects\fermat-weber problem\fermat-weber problem\pvector.h(181): error C2244: 'pvector<pVectorType>::operator /' : unable to match function definition to an existing declaration
1> definition
1> 'pvector<pVectorType> pvector<pVectorType>::operator /(Dividetype &)'
1> existing declarations
1> 'pvector<pVectorType> pvector<pVectorType>::operator /(Dividetype &)'
Error from the compiler. Confounding me, because the definition and the declaration seem to be rather obviously identical.
@_@
Def:
template <class pVectorType>
class pvector
{
public:
/* other declarations not shown */
template <class Dividetype>
pvector<pVectorType> operator/ (Dividetype &var); //divide a pvector by a single var.
};
Dec:
template <class pVectorType, class Dividetype>
pvector<pVectorType> pvector<pVectorType>::operator/ (Dividetype &var)
{
pvector<pVectorType> result;
result.Coord.x /= var; // x/var
result.Coord.y /= var; // y/var
result.findLength(); //update the length variable
return result;
}
How it is used:
for (int i = 0; i < xn.size(); i++)
{
topside = topside + xn.at(i) * cn.at(i) / xn.at(i).findDistance(y);
bottomside = bottomside + cn.at(i) / xn.at(i).findDistance(y);
}
topside = Emn = 1 ( xc / ||x - y||)
bottomside = Emn = 1 ( c / ||x - y||)
By the way, pvector<> is a templated class that has to do with physical vectors. In the final codebox, xn is a vector of pvector<double>, and y is a pvector<double>. For some reason, the overridden operator / doesn't work at all. :/ I think I'll have to just do it dirtily (by manipulating the basic variables directly) if no answer is found.