K
kankowski
Hi, I have two methods A::Conv1 and A::Conv2 that transform coordinates
in two different ways. A:raw() should take the pointer to one
of these methods as the parameter, and call it.
MSVC++ compiler reports: "term does not evaluate to a function taking
4 arguments". If the CONV type is not a pointer to a member function
taking 4 arguments, then what a hell it is?
GCC reports:
"must use .* or ->* to call pointer-to-member function in conv",
which doesn't helps, too.
How should I call the conv function?
class A {
public:
void Conv1(double X, double Y, int& x, int& y);
void Conv2(double X, double Y, int& x, int& y);
typedef void (A::*CONV)(double, double, int&, int&);
void Draw(CONV conv);
void ReDraw();
A() {
_xscale = 0.5, _yscale = 0.5, _xshift = 100, _yshift = 200;
}
private:
double _xscale, _yscale;
int _xshift, _yshift;
};
void A::Conv1(double X, double Y, int& x, int& y) {
x = (int)(X * _xscale), y = (int)(Y * _yscale);
}
void A::Conv2(double X, double Y, int& x, int& y) {
x = (int)(X * _xscale) + _xshift, y = (int)(Y * _yscale) + _yshift;
}
void A:raw(CONV conv) {
int x, y;
conv(0.5, 0.5, x, y); // error C2064: term does not evaluate to a
function
}
void A::ReDraw() {
Draw(Conv1);
}
int main() {
A a;
a.ReDraw();
return 0;
}
in two different ways. A:raw() should take the pointer to one
of these methods as the parameter, and call it.
MSVC++ compiler reports: "term does not evaluate to a function taking
4 arguments". If the CONV type is not a pointer to a member function
taking 4 arguments, then what a hell it is?
GCC reports:
"must use .* or ->* to call pointer-to-member function in conv",
which doesn't helps, too.
How should I call the conv function?
class A {
public:
void Conv1(double X, double Y, int& x, int& y);
void Conv2(double X, double Y, int& x, int& y);
typedef void (A::*CONV)(double, double, int&, int&);
void Draw(CONV conv);
void ReDraw();
A() {
_xscale = 0.5, _yscale = 0.5, _xshift = 100, _yshift = 200;
}
private:
double _xscale, _yscale;
int _xshift, _yshift;
};
void A::Conv1(double X, double Y, int& x, int& y) {
x = (int)(X * _xscale), y = (int)(Y * _yscale);
}
void A::Conv2(double X, double Y, int& x, int& y) {
x = (int)(X * _xscale) + _xshift, y = (int)(Y * _yscale) + _yshift;
}
void A:raw(CONV conv) {
int x, y;
conv(0.5, 0.5, x, y); // error C2064: term does not evaluate to a
function
}
void A::ReDraw() {
Draw(Conv1);
}
int main() {
A a;
a.ReDraw();
return 0;
}