//: C05:PartialOrder2.cpp // From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison. // (c) 1995-2004 MindView, Inc. All Rights Reserved. // See source code use permissions stated in the file 'License.txt', // distributed with the code package available at www.MindView.net. // Reveals partial ordering of class templates. #include using namespace std; template class C { public: void f() { cout << "Primary Template\n"; } }; template class C { public: void f() { cout << "T == int\n"; } }; template class C { public: void f() { cout << "U == double\n"; } }; template class C { public: void f() { cout << "T* used\n"; } }; template class C { public: void f() { cout << "U* used\n"; } }; template class C { public: void f() { cout << "T* and U* used\n"; } }; template class C { public: void f() { cout << "T == U\n"; } }; int main() { C().f(); // 1: Primary template C().f(); // 2: T == int C().f(); // 3: U == double C().f(); // 4: T == U C().f(); // 5: T* used [T is float] C().f(); // 6: U* used [U is float] C().f(); // 7: T* and U* used [float,int] // The following are ambiguous: // 8: C().f(); // 9: C().f(); // 10: C().f(); // 11: C().f(); // 12: C().f(); } ///:~