how to solve these errors

no matching function for call to `Rectangle::Rectangle(std::string&, bool&, int&, Point&)'
no matching function for call to `Square::Square(std::string&, bool&, int&, Point&)'
no matching function for call to `Cross::Cross(std::string&, bool&, int&, Point&)'


The errors are at Assn2.cpp
Square square(shape, containsWS, vert, ordinates[v]);
Rectangle rectangle(shape, containsWS, vert, ordinates[v]);
Cross cross(shape, containsWS, vert, ordinates[v]);
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
 
 * File:   ShapeTwoD.h
  
#ifndef SHAPETWOD_H
#define SHAPETWOD_H
 
#include <string>
#include <math.h>

using namespace std;
 
struct Point {
    int x, y;
};
 
class ShapeTwoD {
public:
    ShapeTwoD(string shapename, bool containsWS);
 
    string getName();
    bool getContainsWarpSpace();
    string toString();
 
    virtual double computeArea();
    virtual bool isPointInShape(Point P, Point* V, int n);
    virtual bool isPointOnShape(Point A, Point B, Point C, int slope, int intercept, int left, int top, int right, int bottom, int dx, int dy);
 
    void setName(string shapename);
    void setContainsWarpSpace(bool containsWS);
 
private:
    string name;
    bool containsWarpSpace;
 
};
 
class Cross : public ShapeTwoD {
public:
    Cross(string shapename = "Cross", bool containsWS, int vertices = 12, Point ordinates[]):ShapeTwoD(shapename, containsWS){}
    int getVert();
    void setVert(int vertices);
    Point getOrd();
    void setOrd(Point ordinates[]);
    virtual double computeArea(Point A[], int vertices);
 
private:
    int vert;
    Point ord[];
 
};
 
class Rectangle : public ShapeTwoD {
public:
    Rectangle(string shapename = "Rectangle", bool containsWS, int vertices = 4, Point ordinates[]):ShapeTwoD(shapename, containsWS){}
    int getVert();
    void setVert(int vertices);
    Point getOrd();
    void setOrd(Point ordinates[]);
    virtual double computeArea(Point A, Point B);
 
private:
    int vert;
    Point ord[];
 
};
 
class Square : public ShapeTwoD {
public:
    Square(string shapename = "Square", bool containsWS, int vertices = 4, Point ordinates[]):ShapeTwoD(shapename, containsWS){}
    int getVert();
    void setVert(int vertices);
    Point getOrd();
    void setOrd(Point ordinates[]);
    virtual double computeArea(Point A, Point B);
 
private:
    int vert;
    Point ord[];
 
};
 
#endif  /* SHAPETWOD_H */
 

}
 
/* 
 * File:   Assn2.cpp
 * Author: Administrator
 *
 * Created on October 29, 2012, 11:58 PM
 */
 
#include "ShapeTwoD.h"
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;
 
// Global declarations
void menu(), option1(), option2(), option3(), option4();
int choice, vert;
string shape, special;
double area;
bool containsWS;
vector<ShapeTwoD> stdv;
 
int main() {
 
    cout << "Welcome to Assn2 program!\n\n";
 
    // When user enters 5 as input, the program quits
    while (choice != 5) {
 
        menu();
         switch (choice) {
 
            case 1:
                option1();
                break;
            case 2:
                option2();
                break;
            case 3:
                option3();
                break;
            case 4:
                option4();
                break;
 
        }
 
    }
}
 
void menu() {
 
    cout << "1)         Input sensor data\n";
    cout << "2)         Compute area (for all records)\n";
    cout << "3)         Print shapes report\n";
    cout << "4)         Sort shape data\n";
    cout << "5)         Quit\n\n";
 
    cout << "Please enter your choice: ";
 
    cin >> choice;
    cout << "\n";
 
}
 
void option1() {
 

 
    cout << "[ Input sensor data ]\n";
 
    cout << "Please enter name of Shape (Cross, Rectangle or Square): ";
    cin >> shape;
 
    cout << "Please enter Special type (NS or WS): ";
    cin >> special;
 
    if (special == "WS") {
 
        containsWS = true;
 
    }
 
    else {
 
        containsWS = false;
 
    }
 
    if (shape == "Cross") {
 
        vert = 12;
 
        for (int v = 0; v < vert; v++) {
 
            Point ordinates[v];
 
            cout << "Please enter x-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].x;
 
            cout << "Please enter y-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].y;
 
            Cross cross(shape, containsWS, vert, ordinates[v]);
 
            stdv.push_back(cross);
        }
 

 
    }
 
    if (shape == "Rectangle") {
 
        vert = 4;
 
        for (int v = 0; v < vert; v++) {
 
            Point ordinates[v];
 
            cout << "Please enter x-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].x;
 
            cout << "Please enter y-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].y;
 
            Rectangle rectangle(shape, containsWS, vert, ordinates[v]);
 
            stdv.push_back(rectangle);
        }
 
    }
 
    else {
 
        shape = "Square";
 
        vert = 4;
 
        for (int v = 0; v < vert; v++) {
 
            Point ordinates[v];
 
            cout << "Please enter x-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].x;
 
            cout << "Please enter y-ordinate of pt. " << (v+1) << ":";
            cin >> ordinates[v].y;
 
            Square square(shape, containsWS, vert, ordinates[v]);
 
            stdv.push_back(square);
        }
 
    }
 
    cout << "Record successfully stored. Going back to main menu";
 
}
 
void option2() {
 
    if (stdv.size() != 0) {
 
        for (int count = 0; count < stdv.size(); count++) {
 
            area = stdv.at(count).computeArea();
            //Debugging purpose
            cout << (count+1) << ")" << stdv.at(count).getName() << "\t" << area;
        }
 
        cout << "Computation completed! (" << stdv.size() << " records were updated)\n\n";
 
    }
 
}
 
Line 191, 214, 237: object takes an array of points as the 4th parameter. You're passing a single point.

You have several other errors also.

Line 39,54,69: You can't specify a defaulted parameter to the left of a non-defaulted parameter. i.e. defaulted aruments must be the right most arguments.

Line 48,63: array must have a size.

Line 85: extraneous }

Topic archived. No new replies allowed.