Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- enum obj_type{obj1,obj2};
- template<int N>
- struct obj
- {
- };
- template <class T>
- class A
- {
- public:
- A(int, int);
- private:
- int a_;
- int b_;
- obj_type type;
- };
- template<>
- A<obj<obj1> >::A(int a, int b):a_(a),b_(b)
- {
- cout<<"case 1"<<endl;
- this->type=obj1;
- }
- template<>
- A<obj<obj2> >::A(int a, int b):a_(a)
- {
- b_=0;
- cout<<"case 2"<<endl;
- this->type=obj2;
- }
- int main()
- {
- A<obj<obj2> > a(1,2);
- return 1;
- }
Add Comment
Please, Sign In to add comment