constructing objects with many points

Shape.h
1
2
3
4
5
6
7
8
9
10
class Shape {

private:
string name;

public:
Shape(name);
string getName();
void setName(string);
};


Triangle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
class Triangle: public Shape {

private:
int x;
int y;

public:
Triangle(name,int[3],int[3]);
int getX();
int getY();
void setX(int);
void setY(int);
};


Triangle.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Triangle::Triangle(string name,int _x[],int_y[]):Shape(name) {
x[] = _x[];
y[] = _y[];

}

int Square::getX() {
return x
}

int Square::getY() {
return y;
}

void Square::setX(int _x) {
x = _x;
}

void Square::setY(int _y) {
y = _y;
}


i need to create triangle that takes in name and 3 points of (x,y). when i try to create an array of triangle on the main Triangle Tri[50]; i got the following errors

Triangle::Triangle(std::string,int*,int*)
candidates expects 3 arguments, 0 provided
Triangle::Triangle(const Triangle&)
candidates expects 1 argument, 0 provided


can pls help me check what is wrong with my constructor?? is it because i am creating an array of objects that store arrays of x and y? so i need to use references and pointers for it?
Triangle.h, Line 8: Triangle(name std::string ,int[3],int[3]);
Triangle.cpp Line 2&3: You cannot assign arrays like that. You should manually copy each element one by one.
then how should i construct it? i need to have 3 arrays of x and y in 1 instance of object triangle
You should manually copy each element one by one.
1
2
3
4
for(int i = 0; i < 3; ++i) {
    x[i] = _x[i];
    y[i] = _y[i];
}
Topic archived. No new replies allowed.