-
Notifications
You must be signed in to change notification settings - Fork 89
Closed
Labels
EssentialsContent for the "essentials" courseContent for the "essentials" course
Milestone
Description
Our current example for function objects is:
struct BinaryFunction {
virtual double operator() (double a, double b) = 0;
};
double binary_op(double a, double b, BinaryFunction &func) {
return func(a, b);
}
struct Add : BinaryFunction {
double operator() (double a, double b) override
{ return a+b; }
};
Add addfunc;
double c = binary_op(a, b, addfunc);
which I think is really bad, since function objects are used with templates since the beginning of the STL. Furthermore, I don't want to encourage the use of inheritance for function objects. We should come up with a better slide here.
Metadata
Metadata
Assignees
Labels
EssentialsContent for the "essentials" courseContent for the "essentials" course