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

Why do this?

Objects can take arguments computed at run-time, specialize functions in a way that simple functions cannot:

	class biggerThan {
	public:
		biggerThan (int x) : testValue(x) { }
		const int testValue;
		bool operator () (int val)
			{ return val > testValue; }
	};

	list<int>::iterator firstBig =
		find_if (aList.begin(), aList.end(), biggerThan(12));

Intro OOP, Chapter 16, Slide 10

In functional languages, this kind of object is sometimes known as a curry.