1 Define an abstract base class called BasicShape The BasicS
1:
Define an abstract base class called BasicShape. The BasicShape class should
have the following members:
a) Protected Member Variable: area (a double used to hold the shape’s area).
b) Private Member Variable: name (a string to indicate the shape’s type)
c) Constructor and Public Member Functions:
BasicShape(double a, string n): A constructor that sets value of member area
with a and member name with n.
calcArea(): This public function should be a pure virtual function.
print(): A public virtual function that only prints the value of data member area
getName():A public function that returns the value of data member name
Solution
Here is the code for you:
#include <iostream>
 using namespace std;
 class BasicShape
 {
 //a) Protected Member Variable: area (a double used to hold the shape’s area).
 protected:
 double area;
 //b) Private Member Variable: name (a string to indicate the shape’s type)
 private:
 string name;
 public:
 //BasicShape(double a, string n): A constructor that sets value of member area with a and member name with n.
 BasicShape(double a, string n)
 {
 area = a;
 name = n;
 }
 //calcArea(): This public function should be a pure virtual function.
 virtual void calcArea() = 0;
 //print(): A public virtual function that only prints the value of data member area.
 virtual void print()
 {
 cout<<\"Area: \"<<area<<endl;
 }
 //getName():A public function that returns the value of data member name.
 string getName()
 {
 return name;
 }
 };

