Hi, I have a base class called ' Shape ' and 3 sub classes namely 'Square' , 'Rectangle' , 'Cross'. I have problem creating my shapes object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Shape *arrayofshape[size];
if (shape == "Square")
{
vertices = 4;
for (int i = 0; i < vertices; i++){
Point ordinates[i];
cout << "Please enter x-ordinate of pt. " << (i+1) << ":";
cin >> ordinates[i].x;
cout << "Please enter y-ordinate of pt. " << (i+1) << ":";
cin >> ordinates[i].y;
Square square(shape, containsWarpSpace, vertices, ordinates[i]);
arrayofShapes[size] = □
size++;
|
Above, shows that my main.cpp is trying to create and storing shape into an array. (But i have an error namely when i'm trying to do so.)
/undefined reference to `Square::Square(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, int, Point)'
I will show more on my .h and .cpp here.
1 2 3 4 5 6 7 8 9 10 11
|
class ShapeTwoD
{
protected:
string name;
bool containsWarpSpace;
double area;
public:
ShapeTwoD(); //Default Constructor
ShapeTwoD(string, bool); //takes in string name and bool containsWarpSpace
|
1 2 3 4 5
|
Square::Square(string ShapeName, bool warpspace, int vertices, Point ordinates[]):ShapeTwoD(ShapeName, warpspace)
{
vert = vertices
ord[] = ordinates[]
}
|
I'm new to c++ thus i really need some help here.
Lastly, where i get my Point ord[] from is i created a Point.h (I do not know where to put this at thus im just trying my luck)
1 2 3 4 5 6 7
|
struct Point {
int x;
int y;
};
|
Would appreciate if i can get help in order for me to solve this and store my shape. Thanks