29 lines
389 B
C++
29 lines
389 B
C++
//: generics/DogsAndRobots.cpp
|
|
// ©2015 MindView LLC: see Copyright.txt
|
|
|
|
class Dog {
|
|
public:
|
|
void speak() {}
|
|
void sit() {}
|
|
void reproduce() {}
|
|
};
|
|
|
|
class Robot {
|
|
public:
|
|
void speak() {}
|
|
void sit() {}
|
|
void oilChange() {
|
|
};
|
|
|
|
template<class T> void perform(T anything) {
|
|
anything.speak();
|
|
anything.sit();
|
|
}
|
|
|
|
int main() {
|
|
Dog d;
|
|
Robot r;
|
|
perform(d);
|
|
perform(r);
|
|
} ///:~
|