Guest User

Untitled

a guest
Dec 16th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class shape
  5. {
  6. public:
  7. int area;
  8. void calc()
  9. {
  10. cout<<sizeof(*this)<<"\n";
  11. }
  12. };
  13. class triangle: public shape
  14. {
  15. public:
  16. int side1,side2,side3;
  17. };
  18. class square: public shape
  19. {
  20. public:
  21. int side1;
  22. };
  23. main()
  24. {
  25. shape *s;
  26. triangle t;
  27. square sq;
  28. s=&t;
  29. s->calc();
  30. s=&sq;
  31. s->calc();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment