#include<iostream>
using namespace std;
class sample
{
protected: int x;
public: void getx()
{
cout<<"Enter value of x"<<endl;
cin>>x;
}
};
class sample1
{
protected:
int y;
public:
void gety()
{
cout<<"Enter value of y"<<endl;
cin>>y;
}
};
class sample2: public sample, public sample1
{
int result;
public:
void multiply()
{
result=x*y;
cout<<"Result is: "<<result<<endl;
}
};
int main()
{
sample2 s;
s.getx();
s.gety();
s.multiply();
return 0;
}
using namespace std;
class sample
{
protected: int x;
public: void getx()
{
cout<<"Enter value of x"<<endl;
cin>>x;
}
};
class sample1
{
protected:
int y;
public:
void gety()
{
cout<<"Enter value of y"<<endl;
cin>>y;
}
};
class sample2: public sample, public sample1
{
int result;
public:
void multiply()
{
result=x*y;
cout<<"Result is: "<<result<<endl;
}
};
int main()
{
sample2 s;
s.getx();
s.gety();
s.multiply();
return 0;
}
No comments:
Post a Comment