#include<iostream>
using namespace std;
class Shape
{
public:
virtual int getPerimeter() = 0;
};
class Rectangle : public Shape
{
int length,breadth;
public:
void in()
{
cin>>length>>breadth;
}
int getPerimeter()
{
return(2*length)+(2*breadth);
}
};
int main()
{
Rectangle obj;
obj.in();
cout <<"Perimeter of Rectangle is: "<<obj.getPerimeter();
return 0;
}
using namespace std;
class Shape
{
public:
virtual int getPerimeter() = 0;
};
class Rectangle : public Shape
{
int length,breadth;
public:
void in()
{
cin>>length>>breadth;
}
int getPerimeter()
{
return(2*length)+(2*breadth);
}
};
int main()
{
Rectangle obj;
obj.in();
cout <<"Perimeter of Rectangle is: "<<obj.getPerimeter();
return 0;
}
not working
ReplyDeletechange:
ReplyDeletevirtual int getPerimeter() = 0;
};
class Rectangle : public Shape
to:
virtual int getPerimeter()=0;
};
class Rectangle:public Shape
to make it work 100%
works
Deleteworking
Delete#include
ReplyDeleteusing namespace std;
class Shape{
public:
virtual int getPerimeter()=0;
};
class Rectangle:public Shape
{
public:
int getPerimeter()
{ int a,b;
cin>>a>>b;
return 2*(a+b);
}
};
int main() {
Shape *ptr = new Rectangle;
cout<<"Perimeter of Rectangle is: "<getPerimeter();
return 0;
}
100 %
Deletethere are error
DeleteThis comment has been removed by the author.
ReplyDelete#include
ReplyDeleteusing namespace std;
class Shape {
public:
virtual int getPerimeter()=0;
};
class Rectangle:public Shape {
public:
int getPerimeter() {
int a,b;
cin>>a>>b;
return 2*(a+b);
}
};
int main() {
Shape *ptr = new Rectangle;
cout<<"Perimeter of Rectangle is: "<getPerimeter();
return 0;
}
//This Gives 100%
This comment has been removed by the author.
DeleteFor Some reason, Copy Paste is not working properly \_("_")_/
Deletebefore getPerimeter(); in main function, add ptr'- >' BUT WITHOUT QUOTES OR SPACES
#include
ReplyDeleteusing namespace std;
class Shape {
public:
virtual int getPerimeter()=0;
};
class Rectangle:public Shape {
public:
int getPerimeter() {
int a,b;
cin>>a>>b;
return 2*(a+b);
}
};
int main() {
Shape *ptr = new Rectangle;
cout<<"Perimeter of Rectangle is: "getPerimeter();
return 0;
}
any one plz send 100%working code of this shape and measurement
ReplyDelete#include
ReplyDeleteusing namespace std;
class Shape {
public:
virtual int getPerimeter()=0;
};
class Rectangle:public Shape {
public:
int getPerimeter()
{
int a,b;
cin>>a>>b;
return 2*(a+b);
}
};
int main() {
Shape *ptr = new Rectangle;
Rectangle r;
int perimeter;
perimeter=r.getPerimeter();
cout<<"Perimeter of Rectangle is: "<<perimeter;
return 0;
}