Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A
- {
- protected:
- int x;
- public:
- void setx();
- void sqr();
- };
- class B:public A
- {
- private:
- int y;
- public:
- void sety();
- void cube();
- };
- void A::setx()
- {
- cin>>x;
- }
- void A::sqr()
- {
- cout<<"Square is:"<<x*x;
- }
- void B::sety()
- {
- cin>>y;
- }
- void B::cube()
- {
- cout<<"Cube is:"<<y*y*y;
- }
- int main() {
- B b;
- b.setx();
- b.sety();
- b.sqr();
- b.cube();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement