Introduction to OOP Chapter 18: Generics : next previous audio real text

Template Functions

The following illustrates a simple template function in C++, and its use.
	template <class T> T max(T left, T right) {
		if (left < right)
			return right;
		return left;
	}

	int a = max(3, 27);
	double d = max(3.14, 2.75); // see how types differ
Intro OOP, Chapter 18, Slide 02