Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. class A {};
  3. class B {};
  4.  
  5. class AA : public A {};
  6. class BA : public A {};
  7.  
  8. class AB : public B {};
  9. class BB : public B {};
  10.  
  11.  
  12. template<typename T>
  13. void MyTemplate(T* ptr)
  14. {
  15. // T is expected to be type A
  16. // Do stuff to type A
  17. }
  18.  
  19. template<typename T>
  20. void MyTemplate(T* ptr)
  21. {
  22. // T is expected to be type B
  23. // Do stuff to type B
  24. }
  25.  
  26.  
  27. AA aa;
  28. AB ab;
  29. BA ba;
  30. BB bb;
  31.  
  32. MyTemplate(&aa); // These two should call into the 1st MyTemplate
  33. MyTemplate(&ab); // These two should call into the 1st MyTemplate
  34. MyTemplate(&ba); // These two should call into the 2nd MyTemplate
  35. MyTemplate(&bb); // These two should call into the 2nd MyTemplate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement