I'm not talking about the getShape.cpp, i'm talking about shape and other derived classes, they shouldn't include getShape.cpp. ON the other hand, getShape.cpp is supposed to include circle.h, rectangle.h and square.h. and Main.cpp is only supposed to include shape.h.
Code:#include <string>
using std::string;
#include <sstream>
#include <iostream>
using namespace std;
#include <iomanip>
#include "circle.h"
#include "square.h"
#include "rectangle.h"
using std::string;
using namespace std;
shape* getShape()
{
do {
string color;
double length, width, rad, side;
string shapetype;
shape *myshape;
cout << "Enter the shape's color (or 'done')..." << endl;
cin >> color;
cout << "Enter shape type..." << endl;
cin >> shapetype;
if (shapetype == "done")
{
return NULL;
}
if (shapetype == "circle")
{
cout << "Enter the radius..." << endl;
cin >> rad;
myshape = new circle(color, rad);
return myshape;
}
if (shapetype == "square")
{
cout << "Enter the side length..." << endl;
cin >> side;
myshape = new square(color, side);
return myshape;
}
if (shapetype == "rectangle")
{
cout << "Enter the length..." << endl;
cin >> length;
cout << "Enter the width..." << endl;
cin >> width;
myshape = new rectangle(color, width, length);
return myshape;
}
else{
cout << "Invalid input" << endl;
continue;
}
}while (true);
}