Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Base{
- private:
- int x;
- public:
- void read_data(){
- cout<<"Enter number"<<endl;
- cin>>x;
- }
- int getx() {return x;}
- };
- class Derived: public Base{
- private:
- int y;
- public:
- void get_data(){
- cout<<"Enter number"<<endl;
- cin>>y;
- }
- int product(){
- return getx()*y;
- }
- };
- int main()
- {
- Derived obj;
- obj.read_data();
- obj.get_data();
- cout<<"product is" <<obj.product();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment