Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Parnet{
- protected:
- int x;
- };
- class Child : public Parnet{
- protected:
- int y;
- };
- class Grand_child : public Child{
- protected:
- int z;
- public:
- void get()
- {
- cout<<"Enter three numbers"<<endl;
- cin>>x>>y>>z;
- }
- void sum(){
- cout<<"Sum is "<<x+y+z;
- }
- };
- int main()
- {
- Grand_child obj;
- obj.get();
- obj.sum();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment