C++ Lecture 7

[Previous Lecture] [Lecture Index] [Next Lecture]

Defensive Class Design

Common problems caused by mis-use of classes: Solution: design classes to deal with or prevent misuse Note: If your destructor does anything, you probably need a copy constructor and assignment operator.

Intro to Templates

Example:
    template <class XYZ>
    XYZ &
    myMin(XYZ &a, XYZ &b)
    {
	if (a < b)
	    return a;
	else
	    return b;
    }

    int
    main()
    {
	cout << myMin(10, 4) << endl;
	cout << myMin(-2.4, 8.9) << endl;
	return 0;
    }

Standard Template Library Intro

Library has templates for Containers:
[Previous Lecture] [Lecture Index] [Next Lecture]