Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class T>
- class A
- {
- T a;
- public:
- A(T _a): a(_a){}
- void print(){cout<<a<<endl;}
- };
- template <class T>
- class B: public A<T>
- {
- int v;
- public:
- B(T a,int _v): A<T>(a), v(_v) {}
- void print(){for(int i=0;i<v;i++) A<T>::print();}
- };
- int main()
- {
- B <double> v(3.5,2);
- v.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment