Introduction to OOP: Chapter 16 : A Case Study : The STL [next] [previous] [audio] [real] [text]

Function Objects

Created like an instance of a class, works like a function.

class WidgetTester {
public:
	WidgetTester (int id) : test_id(id) { }
	int test_id;

		// define the function call operator
	bool operator () (Widget & wid)
		{ return wid.id() == test_id; }
};
Intro OOP, Chapter 16, Slide 15