Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. template<typename T>
  6. class Base {
  7. public:
  8. int var;
  9. Base(){
  10. var = 5;
  11. }
  12. };
  13.  
  14. template<class T>
  15. class Derived : public Base<T> {
  16. public:
  17. Derived() {
  18. this.var = 10;
  19. }
  20. };
  21.  
  22. int main()
  23. {
  24. Base<int>* pntr = new Base;
  25. Derived<int>* pntr2 = (*Derived)pntr;
  26. Base<int>* pntr3 = dynamic_cast<*Base>(pntr2);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement