Advertisement
AlijaHrnjic

Untitled

Apr 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include<iostream>
  2. struct animal{
  3. animal(int i){std::cout << "animal constructor " << i << std::endl;}
  4. animal(){std::cout << "animal constructor" << std::endl;}
  5. // virtual void foo()=0;
  6. // ~animal(){std::cout<<"desanimal"<<std::endl;}
  7. };
  8. struct lion :virtual public animal{
  9. lion(int i) animal{i} {std::cout << "lion constructor " << i << std::endl;}
  10. lion(){std::cout << "lion constructor" << std::endl;}
  11. // void foo()override{std::cout << "lion's foo" <<std::endl;}
  12. // ~lion(){std::cout<<"deslion"<<std::endl;}
  13. };
  14. struct tiger : virtual public animal{
  15. tiger(int i) : animal{i} {std::cout << "tiger constructor " << i << std::endl;}
  16. tiger(){std::cout << "tiger constructor" << std::endl;}
  17.  
  18. // void foo()override{std::cout << "tiger's foo" <<std::endl;}
  19. };
  20.  
  21. // struct puma : public animal{
  22. // puma(){std::cout << "puma constructor" << std::endl;}
  23. // };
  24.  
  25. struct liger : public lion,public tiger{
  26. liger(){std::cout << "liger constructor" << std::endl;}
  27. liger(int i):lion{i},tiger{i}{std::cout << "liger constructor " << i << std::endl;}
  28.  
  29. };
  30.  
  31. int main(){
  32. liger l(5);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement