Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- struct animal{
- animal(int i){std::cout << "animal constructor " << i << std::endl;}
- animal(){std::cout << "animal constructor" << std::endl;}
- // virtual void foo()=0;
- // ~animal(){std::cout<<"desanimal"<<std::endl;}
- };
- struct lion :virtual public animal{
- lion(int i) animal{i} {std::cout << "lion constructor " << i << std::endl;}
- lion(){std::cout << "lion constructor" << std::endl;}
- // void foo()override{std::cout << "lion's foo" <<std::endl;}
- // ~lion(){std::cout<<"deslion"<<std::endl;}
- };
- struct tiger : virtual public animal{
- tiger(int i) : animal{i} {std::cout << "tiger constructor " << i << std::endl;}
- tiger(){std::cout << "tiger constructor" << std::endl;}
- // void foo()override{std::cout << "tiger's foo" <<std::endl;}
- };
- // struct puma : public animal{
- // puma(){std::cout << "puma constructor" << std::endl;}
- // };
- struct liger : public lion,public tiger{
- liger(){std::cout << "liger constructor" << std::endl;}
- liger(int i):lion{i},tiger{i}{std::cout << "liger constructor " << i << std::endl;}
- };
- int main(){
- liger l(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement