#include <iostream>
using namespace std;
class A
{
public:
int pen;
void display()
{
cin>>pen;
}
};
class B
{
public:
int price;
void display()
{
cin>>price;
}
};
class C: public A, public B
{
public:
void display()
{
A::display();
B::display();
cout<<pen*price;
}
};
int main()
{
C sample;
sample.display();
return 0;
}
using namespace std;
class A
{
public:
int pen;
void display()
{
cin>>pen;
}
};
class B
{
public:
int price;
void display()
{
cin>>price;
}
};
class C: public A, public B
{
public:
void display()
{
A::display();
B::display();
cout<<pen*price;
}
};
int main()
{
C sample;
sample.display();
return 0;
}
change "class C: public A, public B"
ReplyDeleteto "class C:public A,public B"
for 100% result
not working only 66%
ReplyDelete#include
ReplyDeleteusing namespace std;
class A{protected:int a;
public:void display(){cin>>a;}
};
class B{protected:int b;
public:void display(){cin>>b;}
};
class C:public A,public B{public:
void display(){}
void show(){cout<display();
B *bb;
bb=&sample;
bb->display();
sample.display();
sample.show();
return 0;}