Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- using namespace std;
- template<typename T>
- class Base {
- public:
- int var;
- Base(){
- var = 5;
- }
- };
- template<class T>
- class Derived : public Base<T> {
- public:
- Derived() {
- this.var = 10;
- }
- };
- int main()
- {
- Base<int>* pntr = new Base;
- Derived<int>* pntr2 = (*Derived)pntr;
- Base<int>* pntr3 = dynamic_cast<*Base>(pntr2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement