R
Ramon F Herrera
(newbie alert)
On several occasions my C++ code (sans class stuff) is working
perfectly, but being notorious for getting meeself in trouble, I
embark on a project to "classify" my code.
This is a previous example, a learned lesson:
Pre-Class Code:
for_each(m1, m2, &rhs_callback);
Post-Class code:
for_each(m1, m2, boost::bind(&Evaluate::rhs_callback, this, _1));
I don't even pretend to understand what's going there, I simply copy &
pasted the snippet, after thanking profusely the kind poster who
provided the black-box magic recipe. (it was in the Boost NG).
The following is my latest code that is in class-related trouble:
Pre-Class code:
(global)
struct point {
double x;
double y;
};
list<point> pointKeeper;
(inside class)
bool x_comparison(const point& pt1, const point& pt2)
{
return pt1.x < pt2.x;
}
pointKeeper.sort(x_comparison); // This won't compile :-(
I have tried things like:
pointKeeper.sort(ClassName::x_comparison);
But it won't compile.
Thanks for your expert assistance...
-Ramon
On several occasions my C++ code (sans class stuff) is working
perfectly, but being notorious for getting meeself in trouble, I
embark on a project to "classify" my code.
This is a previous example, a learned lesson:
Pre-Class Code:
for_each(m1, m2, &rhs_callback);
Post-Class code:
for_each(m1, m2, boost::bind(&Evaluate::rhs_callback, this, _1));
I don't even pretend to understand what's going there, I simply copy &
pasted the snippet, after thanking profusely the kind poster who
provided the black-box magic recipe. (it was in the Boost NG).
The following is my latest code that is in class-related trouble:
Pre-Class code:
(global)
struct point {
double x;
double y;
};
list<point> pointKeeper;
(inside class)
bool x_comparison(const point& pt1, const point& pt2)
{
return pt1.x < pt2.x;
}
pointKeeper.sort(x_comparison); // This won't compile :-(
I have tried things like:
pointKeeper.sort(ClassName::x_comparison);
But it won't compile.
Thanks for your expert assistance...
-Ramon