#include <iostream>
using namespace std;
class Shape
{
protected:
double x, y;
public:
void set_dim(double i, double j=0)
{
x = i;
y = j;
}
virtual int getArea() = 0;
};
class Rectangle : public Shape {
public:
int getArea() {
cout <<"Area of Rectangle is:"<< x * y << "\n";
}
};
main(void)
{
Shape *p;
Rectangle r;
int l,b;
cin>>l>>b;
p = &r;
p->set_dim(l, b);
p->getArea();
return 0;
}
using namespace std;
class Shape
{
protected:
double x, y;
public:
void set_dim(double i, double j=0)
{
x = i;
y = j;
}
virtual int getArea() = 0;
};
class Rectangle : public Shape {
public:
int getArea() {
cout <<"Area of Rectangle is:"<< x * y << "\n";
}
};
main(void)
{
Shape *p;
Rectangle r;
int l,b;
cin>>l>>b;
p = &r;
p->set_dim(l, b);
p->getArea();
return 0;
}
Measure the Area
ReplyDeleteit not working at 71% only
ReplyDeletemine too. Only 71%
Deletebro Im getting 85%
ReplyDelete#include
ReplyDeleteusing namespace std;
class Shape
{
protected:
double x, y;
public:
void set_dim(double i, double j=0)
{
x = i;
y = j;
}
virtual int getArea()=0;
};
class Rectangle:public Shape{
public:
int getArea() {
cout <<"Area of Rectangle is:"<< x * y << "\n";
}
};
main(void)
{
Shape *p;
Rectangle r;
int l,b;
cin>>l>>b;
p = &r;
p->set_dim(l, b);
p->getArea();
return 0;
}
USE THIS GIVES 100%
DeleteGG Bois
Deletegg
Delete