Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class shape
- {
- public:
- int area;
- void calc()
- {
- cout<<sizeof(*this)<<"\n";
- }
- };
- class triangle: public shape
- {
- public:
- int side1,side2,side3;
- };
- class square: public shape
- {
- public:
- int side1;
- };
- main()
- {
- shape *s;
- triangle t;
- square sq;
- s=&t;
- s->calc();
- s=&sq;
- s->calc();
- }
Advertisement
Add Comment
Please, Sign In to add comment