// generics/DogsAndRobots.cpp // (c)2016 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. class Dog { public: void speak() {} void sit() {} void reproduce() {} }; class Robot { public: void speak() {} void sit() {} void oilChange() { }; template void perform(T anything) { anything.speak(); anything.sit(); } int main() { Dog d; Robot r; perform(d); perform(r); }