fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class CBase{};
  5.  
  6. class CDerivedA: public CBase{};
  7.  
  8. class CDerivedB : public CBase{};
  9.  
  10. class CDerivedC : public CBase{};
  11.  
  12. template <typename T>
  13. void Draw(T* face)
  14. {
  15. cout<<"Base"<<endl;
  16. }
  17.  
  18. template <>
  19. void Draw<>(CDerivedA* face)
  20. {
  21. cout<<"A"<<endl;
  22. }
  23.  
  24. template <>
  25. void Draw<>(CDerivedB* face)
  26. {
  27. cout<<"B"<<endl;
  28. }
  29.  
  30. int main() {
  31. CBase* a = new CDerivedA ();
  32. CBase* b = new CDerivedB ();
  33. CBase* c = new CDerivedC ();
  34.  
  35. Draw(a);
  36. Draw(b);
  37. Draw(c);
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Base
Base
Base